snarfed / bridgy

📣 Connects your web site to social media. Likes, retweets, mentions, cross-posting, and more...
https://brid.gy
Creative Commons Zero v1.0 Universal
702 stars 51 forks source link

Bluesky publish: support @-mentions, hashtags, links #1661

Open snarfed opened 5 months ago

snarfed commented 5 months ago

Most or all of the work here is https://github.com/snarfed/granary/issues/675, filing this just to track on the Bridgy side. cc @JoelOtter

singpolyma commented 5 months ago

Just came here to report the @-mention thing, so glad it's known :)

snarfed commented 5 months ago

Yes!

@singpolyma out of curiosity, what does your Bluesky @-mention HTML look like?

singpolyma commented 5 months ago

https://brid.gy/log?module=default&start_time=1707315789&key=agdicmlkLWd5cmgLEg1QdWJsaXNoZWRQYWdlIkFodHRwczovL3Npbmdwb2x5bWEubmV0L2FjdGlvbnN0cmVhbS9yZXBseS1odHRwcy1ic2t5LWFwcC1wcm9maWxlLwwLEgdQdWJsaXNoGICA-NGmj4cJDA

snarfed commented 5 months ago

Thanks! Looks like it's:

@<span class="vcard"><a class="fn url" href="http://ipg.gay">ipg.gay</a></span>

A couple interesting things here. First, it links to their handle's web site directly, not their bsky.app profile URL, and second, the @ character is outside the link. Both of those make it a bit trickier to reliably/safely interpret the intent here as an @-mention and not a normal link. (As a comparison, Bridgy Fed's @-mention detection requires the @ character inside the link.)

snarfed commented 5 months ago

Apart from @-mentions specifically, I'll also echo here what I mentioned in https://github.com/snarfed/granary/issues/675 in general : this is going to be difficult to implement. We have to "disassemble" span-based HTML markup into Bluesky index-based facets. For arbitrary content HTML, we have to parse it, extract just the tags we care about (currently links and microformats2 hashtag u-categories), discard other tags (including overlapping ones like the span here), extract the plain text, calculate the start and end indices of the tags we care about into the plain text, convert those indices to bytes in the HTML document's character encoding, and populate all of that into Bluesky facets. Phew.

@kevinmarks sent the old XOXO parser as an example that does this, which is great! Still though. This feels like a nontrivial project.

singpolyma commented 5 months ago

Happy to make changes if needed, but to me it's a mention because it mentions someone (via vcard) the @ sign isn't part of the microformats and so not part of the semantics.

As for the link pointing directly at their handle, it shouldn't be too hard to discover bluesky id from handle right? That's what bluesky is doing internally.

snarfed commented 5 months ago

h-card/vcard is reasonable! We'd probably need a fallback, since most user-level sites/CMSes don't let people attach arbitrary classes to links, but the fallback can be expecting @ inside the link like BF does.

kevinmarks commented 5 months ago

There's a public bluesky api to map handle to id that does not need auth

On Wed, 7 Feb 2024, 15:33 Stephen Paul Weber, @.***> wrote:

Happy to make changes if needed, but to me it's a mention because it mentions someone (via vcard) the @ sign isn't part of the microformats and so not part of the semantics.

As for the link pointing directly at their handle, it shouldn't be too hard to discover bluesky id from handle right? That's what bluesky is doing internally.

— Reply to this email directly, view it on GitHub https://github.com/snarfed/bridgy/issues/1661#issuecomment-1932301334, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAYFQA5VQYRLB7FIBSASZLYSONFRAVCNFSM6AAAAABC23QINSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZSGMYDCMZTGQ . You are receiving this because you were mentioned.Message ID: @.***>

snarfed commented 5 months ago

Yup! Linking to their domain is manageable for Bridgy classic (here) because we know which specific silo you're POSSEing to. It's trickier in Bridgy Fed - which shares much of the underlying logic - because there we federate the same post to multiple networks. In that case, we wouldn't know which of those networks to try to convert this @-mention to, if any.

singpolyma commented 5 months ago

Yup! Linking to their domain is manageable for Bridgy classic (here) because we know which specific silo you're POSSEing to. It's trickier in Bridgy Fed - which shares much of the underlying logic - because there we federate the same post to multiple networks. In that case, we wouldn't know which of those networks to try to convert this @-mention to, if any.

Right, in that case you would have to check which fed protocols the handle supports

snarfed commented 5 months ago

I more want to know the author's intent. May be worth discussing in #microformats.

One approach would be to try to convert to a native @-mention in each network separately. We don't necessarily know if that's what the author themselves want though? Ugh.

JoelOtter commented 5 months ago

One approach would be to try to convert to a native @-mention in each network separately. We don't necessarily know if that's what the author themselves want though? Ugh.

This is something I was meaning to bring up separately. I think it is separate to this ticket though.

snarfed commented 3 months ago

Got hashtags working! https://bsky.app/profile/snarfed.bsky.social/post/3kp3bfhk25d2c