snarfed / bridgy-fed

🌉 A bridge between decentralized social network protocols
https://fed.brid.gy
Creative Commons Zero v1.0 Universal
566 stars 30 forks source link

ActivityPub => ATProto @-mentions #957

Closed snarfed closed 4 months ago

snarfed commented 5 months ago

The AS2 tags coming from eg Mastodon have displayName as the full @user@instance handle, but only @user in text, so we don't currently find them.

Example AS2:

{
  "type": "Note",
  "id": "https://indieweb.social/users/snarfed/statuses/112276475646675266",
  "url": "https://indieweb.social/@snarfed/112276475646675266",
  "content": "<p><span class=\"h-card\" translate=\"no\"><a href=\"https://atproto.brid.gy/r/https://bsky.app/profile/snarfed.org\" class=\"u-url mention\">@<span>snarfed.org</span></a></span> funny</p>",
  "tag": [{
      "type": "Mention",
      "href": "https://atproto.brid.gy/ap/did:plc:fdme4gb7mu7zrie7peay7tst",
      "name": "@snarfed.org@atproto.brid.gy"
    }],
  "..."
}

...which we convert to this AS1:

{
  "objectType": "comment",
  "id": "https://indieweb.social/users/snarfed/statuses/112276475646675266",
  "url": "https://indieweb.social/@snarfed/112276475646675266",
  "content": "<p><span class=\"h-card\" translate=\"no\"><a href=\"https://atproto.brid.gy/r/https://bsky.app/profile/snarfed.org\" class=\"u-url mention\">@<span>snarfed.org</span></a></span> funny</p>",
  "tags": [{
      "objectType": "mention",
      "displayName": "@snarfed.org@atproto.brid.gy",
      "url": "did:plc:fdme4gb7mu7zrie7peay7tst"
    }],
  "..."
}
qazmlp commented 5 months ago

I wonder if those are just applied in order of appearance to the class=mention links, without comparisons at all, or if they're wholly separate and the links are resolved via WebFinger and cached.

There are also a few applications (HubZilla?) that use different formatting like not including the '@' in the mention link.

snarfed commented 5 months ago

Gory details on ActivityPub and Mastodon specific @-mention AS2 requirements in #493. We figured those out a while back, and we have bridged @-mentions working for web <=> AP (both directions) and web => ATProto, so this is AP => ATProto specific somehow.

qazmlp commented 5 months ago

As mentioned in https://github.com/snarfed/bridgy-fed/issues/959#issuecomment-2058838357, it doesn't seem like "content" and "tag" necessarily have any meaningful relation for processing in the fediverse. You'll probably have to resolve <a href="…">…</a> URLs to accounts (and maybe posts for quote boosts?) via active requests at some points.

While Mastodon uses microformats to potentially make those easier to recognise, it says these are deprecated. Pixelfed also applies u-url, but doesn't wrap mentions in an h-card, which seems not entirely compatible with Mastodon's concept where u-url has multiple meanings (though does always point to an ActivityPub Object).

snarfed commented 4 months ago

Fixed! Example: https://indieweb.social/@snarfed/112474851557434046 => https://bsky.app/profile/snarfed.indieweb.social.ap.brid.gy/post/3kswvsvselmu2

qazmlp commented 4 months ago

Does this include @-mentions of AP users (bridged/non-bridged)?

Edit: Just saw that local mentions are translated as bridged, at least if possible 👍

snarfed commented 4 months ago

Reopening! @ShreyanJain9 reported a mention that didn't work, https://hachyderm.io/@shreyan/112477634954680219 => https://bsky.app/profile/shreyan.hachyderm.io.ap.brid.gy/post/3ksy5eoplkdt2

snarfed commented 4 months ago

This definitely regressed somehow. 😕 More examples: https://bsky.app/profile/did:plc:whco57z2rz6jvi3wv3o56jdi

snarfed commented 4 months ago

Fixed! Example: https://indieweb.social/@snarfed/112532760605114080 => https://bsky.app/profile/snarfed.indieweb.social.ap.brid.gy/post/3ktqmr2aigua2