Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ATProto => ActivityPub link previews #958

Open
Tracked by #381
snarfed opened this issue Apr 15, 2024 · 11 comments
Open
Tracked by #381

ATProto => ActivityPub link previews #958

snarfed opened this issue Apr 15, 2024 · 11 comments
Labels

Comments

@snarfed
Copy link
Owner

snarfed commented Apr 15, 2024

They're partially making it over, but not all the way. Example Bluesky post and bridged fediverse post.

image

Bluesky record, pruned:

{
  "cid" : "bafyreicxnk4ipbjh5g3rikqa3hlmzee4dl3mdgahif7n3aezwdixggsaau",
  "uri" : "at://did:plc:3ljmtyyjqcjee2kpewgsifvb/app.bsky.feed.post/3kq6zy5it5k2i",
  "value" : {
    "$type" : "app.bsky.feed.post",
    "createdAt" : "2024-04-15T19:54:10.898Z",
    "embed" : {
      "$type" : "app.bsky.embed.external",
      "external" : {
        "description" : "",
        "thumb" : {
          "$type" : "blob",
          "mimeType" : "image/jpeg",
          "ref" : {"$link" : "bafkreiemenxtcacg5p4m4ck6iofqgcqyfulhbwq5lsatrwgd4kvvbtxjz4"},
          "size" : 377240
        },
        "title" : "Adeline Software International - Wikipedia",
        "uri" : "https://en.wikipedia.org/wiki/Adeline_Software_International"
      }
    },
    "text" : "and now with a link"
  }
}

AS1:

{
  "objectType": "note",
  "id": "at://did:plc:3ljmtyyjqcjee2kpewgsifvb/app.bsky.feed.post/3kq6zy5it5k2i",
  "url": "https://bsky.app/profile/did:plc:3ljmtyyjqcjee2kpewgsifvb/post/3kq6zy5it5k2i",
  "content": "and now with a link",
  "attachments": [{
      "objectType": "link",
      "url": "https://en.wikipedia.org/wiki/Adeline_Software_International",
      "displayName": "Adeline Software International - Wikipedia",
      "image": "https://morel.us-east.host.bsky.network/xrpc/com.atproto.sync.getBlob?did=did:plc:3ljmtyyjqcjee2kpewgsifvb&cid=bafkreiemenxtcacg5p4m4ck6iofqgcqyfulhbwq5lsatrwgd4kvvbtxjz4"
    }]
}

AS2:

{
  "type": "Note",
  "id": "https://atproto.brid.gy/convert/ap/at://did:plc:3ljmtyyjqcjee2kpewgsifvb/app.bsky.feed.post/3kq6zy5it5k2i",
  "url": "https://fed.brid.gy/r/https://bsky.app/profile/did:plc:3ljmtyyjqcjee2kpewgsifvb/post/3kq6zy5it5k2i",
  "content": "and now with a link",
  "attachment": [{
      "url": "https://en.wikipedia.org/wiki/Adeline_Software_International",
      "image": "https://morel.us-east.host.bsky.network/xrpc/com.atproto.sync.getBlob?did=did:plc:3ljmtyyjqcjee2kpewgsifvb&cid=bafkreiemenxtcacg5p4m4ck6iofqgcqyfulhbwq5lsatrwgd4kvvbtxjz4",
      "name": "Adeline Software International - Wikipedia"
    }],
  },
}
@qazmlp
Copy link

qazmlp commented Apr 16, 2024

For Mastodon, you'll want to put the image URL in the attachment's icon or icon.url property, according to this code.

@qazmlp
Copy link

qazmlp commented Apr 16, 2024

Pixelfed will drop any posts with link attachments that aren't replies, as it's strict about supported attachment types.
Edit: Fixed URL.

I think that, generally speaking, you definitely should add a "type" property to the attachment to signal intent. Judging by the commented-out code in Pixelfed (second link), PeerTube ~~uses/~~used "type": "Link" for this purpose.

It seems that PeerTube (now?) sends Video Objects instead of Notes, though, and creates attachments with "type": "Video".
It ignores the "attachment" property on Notes, as far as I can tell, so if someone would comment on a video with an attachment-only link on Bsky, that link would be lost there.

@snarfed
Copy link
Owner Author

snarfed commented Apr 16, 2024

I'm actually surprised that fediverse servers, or at least Mastodon, use anything in attachments for link previews at all, if it even does? Mastodon famously refetches links itself to generate previews instead of trusting the remote server that sent the activity: mastodon/mastodon#4486 , mastodon/mastodon#23662

@qazmlp
Copy link

qazmlp commented Apr 16, 2024

It's an edge case of a fallback, yeah. Mastodon does not actually support link attachments outside the content at all, but if it receives an attachment that it doesn't support, it will reliably render that as some form of clickable placeholder.
(The app is a little better about telling you what's behind there, in my experience.)

Thinking about it, the semantic intention of icon is most likely "file icon" or "favicon".
(I don't know how it renders in practice. I think you can also colour in that rectangle with a Blurhash.)

I noticed that Akkoma can apparently show some kind of summary text when it can't show the attachment preview, but I can't read its source code well enough to know how to make use of that.

I think it's fair to say that "links as attachments" just isn't something that's widely supported by Fediverse apps, even if in my opinion it should be, and could be a way to not overwhelm the link destination.

@qazmlp
Copy link

qazmlp commented Apr 16, 2024

It breaks very badly in some third-party clients, though:

Elk.zone - tall image

image

Similar issue in Phanpy:
image

I can't even click through there (in either case), even though technically the information is provided by Mastodon:
image

@snarfed
Copy link
Owner Author

snarfed commented Apr 16, 2024

It breaks very badly in some third-party clients, though:

Right, and it breaks in Mastodon itself too, eg the screenshot in the original description here.

The AS2 attachment here was converted automatically by granary from the embed facet in the Bluesky post. I wasn't intentionally trying to generate a link preview in the fediverse; I expected Mastodon and most others to fetch the link and generate the preview themselves, like they usually do.

Regardless, you're right, type: Link should hopefully fix this. 🤞

@qazmlp
Copy link

qazmlp commented Apr 16, 2024

Regardless, you're right, type: Link should hopefully fix this. 🤞

Unfortunately not at first, since I don't think anything actually supports that kind of attachment.
It would make it decently easy for Mastodon et al to add support for it, though, as then there'd be a clear intent.

The only way to make links work reliably and render correctly, currently, is to insert them into the post content for (almost all?) fediverse apps, unfortunately, since they follow Twitter's data model in that regard.

@snarfed
Copy link
Owner Author

snarfed commented Apr 29, 2024

Looking at this again, I'm inclined to just remove these attachments altogether and let fediverse servers generate their own link previews, since that's the happier and more common path in the fediverse.

snarfed added a commit to snarfed/granary that referenced this issue Apr 29, 2024
@snarfed snarfed reopened this May 2, 2024
@snarfed
Copy link
Owner Author

snarfed commented May 2, 2024

Reopening this, @bnewbold inspired me to try again to see if I can get fedi servers to render link previews that are separate from post text. I never actually tried with type: Link. I should!

@snarfed snarfed added the now label May 2, 2024
@bnewbold
Copy link

bnewbold commented May 3, 2024

to clarify, what i was reporting was that sometimes there is a bsky post with no URL in the text and only a card/embed. In those cases, it feels like the URL from the embed should be appended to the end of the post text (with a <br> or two?), so that the link preview will render. Otherwise there is just the post text commenting on the referenced content, but no URL or link preview at all on the AP side.

At least in the case of:

just remove these attachments altogether and let fediverse servers generate their own link previews, since that's the happier and more common path in the fediverse

@snarfed
Copy link
Owner Author

snarfed commented May 3, 2024

Right! I get it. I generally try pretty hard to not modify users' original post text at all, so I first plan to try to get the AS2 equivalent of a Link attachment without its URL in the post text working. If that doesn't work, I can consider appending the URL to the post text.

@snarfed snarfed added now and removed now labels May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants