-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add Bluesky support #1453
Comments
Interesting, they're adding app passwords as a stopgap until they implement full OAuth. https://staging.bsky.app/profile/pfrazee.com/post/3jtivygsgk72w cc @capjamesg @aaronpk |
granary now has much of the API support it would need, and Bridgy Fed support will still take some work, not to mention Bluesky's federation isn't on yet anyway, so maybe we should do this after all. |
I would be a user of this and would also be happy to test. |
Will be glad to test this! I think I would actually prefer to implement something internally for myself, but I've been a bridgy user for a long time for the birdsite integration, and now that birdsite is a hellhole, why not try it for Bluesky, if such an opportunity presents itself? |
Generic instructions on adding a new silo: https://bridgy.readthedocs.io/#adding-a-new-silo |
Thinking of picking this up - does Bridgy have any existing flow for accepting (app) passwords or would you rather wait until it actually has OAuth? |
@JoelOtter hey, awesome, that'd be great! App passwords are fine, OAuth isn't in Bluesky team's near term plans. Bridgy uses https://github.com/snarfed/oauth-dropins (https://oauth-dropins.appspot.com/ ) for auth, so the first step is probably to add it there. You could start with the code in https://github.com/snarfed/bluesky-atom/blob/main/app.py and HTML form in https://github.com/snarfed/bluesky-atom/blob/main/templates/index.html , extract them out, and use them to add Bluesky to oauth-dropins. It wouldn't need the OAuth handlers, but it would need a Alternatively we could just do all of that in Bridgy itself, directly, and ignore oauth-dropins. Right now all silo auth in Bridgy goes through oauth-dropins handlers, but that might not be strictly necessary. I don't know which path ^ I prefer yet. Feel free to poke at the code and see what you think. |
Thanks! I'll have a look at the dropins. From my reading of the code this evening it does seem like unpicking the auth handler stuff would be rather painful so I think adding it to oauth-dropins makes sense, as long as you don't object to that repo having an oauth dropin that isn't, y'know, oauth |
Hah, understood, and yeah adding Bluesky to oauth-dropins is totally ok with me. Even ignoring granary and Bridgy itself entirely, that would be a great first step, and largely necessary. |
Spent a few hours on this today. I've added a pretty simple auth handler to oauth-dropins, and the associated bits on Bridgy. I think now I need to add some more stuff to Granary - at minimum, it's complaining that Couple of notes:
I'll keep chipping away at this. Having fun! But brain a bit melted now. |
Awesome progress! Thanks for the details, and for sticking with it through those stumbling blocks. In general you'll want to I run flake8 occasionally, but it's not yet integrated into CI or anything. Feel free to use a linter locally for your code as long as it matches the rest of the project's style! And apologies for the two space indents, these projects all started long ago when I was young and foolish. 🤷♂️ |
@JoelOtter also for projects like this where you're making interdependent changes to oauth-dropins, granary, and Bridgy, I recomend installing them with |
Yep I've done so, the docs are great :) |
Something I've run into, not sure if it's a Bridgy thing or a Granary thing - shares/reposts on Bluesky don't appear to have an ID at all like they do on Twitter/Mastodon, which means the handling in |
Huh! At minimum they'll have a CID at the ATP level. Is that not exposed at the Bluesky lexicon level? If not, we can always synthesize an id, eg |
Managed to get the repost URL out of the |
Whoa, that's awesome, so cool! Congrats! |
Here's an interesting note: Bluesky doesn't count quote posts as reposts, and there's no way to see who quote-posted something (as far as I can tell?). A quote post itself is just a regular post with an embed, like a link would be. It's an interesting implementation and I kind of like it. EDIT: Looks like we might be able to get them from notifications though I don't super love that approach. |
Interesting indeed! The UX-level semantics don't matter too much to us here, but the choices of what to backfeed, and how we fetch that, obviously do. Bridgy/granary do have precedent for getting some backfed data from notifications, I think we currently do it for GitHub, at least, if not others. Regardless though, feel free to ship the first version of this without quotes if you want! |
Yeah I think first version will just be backfeeding of likes, reposts and replies. Publishing after that, then quotes later probably. |
Would you prefer individual GH issues be created for each of those or shall we just use this issue to track the whole thing? |
Up to you! I'm not too particular. |
Replies working now :) I'm struggling to test the actual webmention sending. It seems to discover the syndication links fine but doesn't send anything - is that a separate job on the background worker or should it be sending as part of the regular poll? |
Woo, congrats! Yeah those are tasks run by Cloud Tasks. Locally, you can trigger them manually: https://bridgy.readthedocs.io/#development , search for To test a poll or propagate task. |
Yeah turned out I needed to adjust the URL canonicaliser for Bluesky - Bluesky doesn't respond to HEAD requests, interestingly, so needed to disable the redirect testing. Current state of affairs: it sends webmentions! I'm sending them to webmention.io which rejects them because it can't hit localhost, obviously. However I think more work needs done because the source URL looks like this:
I think I need to do something here, either use CIDs instead of ATP URIs or just URL-encode them. Is there additional stuff I need to add to the Bluesky source in order for the |
Did some digging into this and I think there are a few interlinking issues with my current implementation:
However, if I hack some stuff in to fix the above, it does actually at least fetch posts properly via the |
Huge progress! Congrats! Yeah "post id" in granary/Bridgy is generally just an id, not a full URI, so I'd recommend switching to just CID, as you mentioned. Hopefully that should fix those URLs. Not sure about activities vs objects getting stored, but I'm happy to look at a draft PR any time. Congrats again, seems like you're almost there! |
Have done a bit of research and I'm now unsure/confused as to whether using CIDs is the right move - CIDs are hashes of the content, so are not fixed for a given post and could feasibly change if, for example, Bluesky adds editing support. There's also no way to query the API by CID; it's essentially a content-integrity thing, I think. URIs are the only real supported thing. What I could do is split URIs up into DIDs and Record Keys. This could then be reformatted into a URI, as we have enough information with those two bits. I'm unsure how invasive a change into Bridgy/Granary this would be though, might need to add lots of silo-specific logic which might mean extending the Source class. Are IDs in Bridgy's DB unique per silo, per user, or globally? |
Yes! Good point about CIDs. Rkeys are a great idea, those should work fine, they'll have a slash in them that would need to be URL-encoded, but that's fine. Actually even just the TID would be fine, which doesn't have the slash. Post ids are expected to be unique per silo, not globally. |
Federation is another wrinkle here. TIDs have to be unique per PDS, but not across them. I don't think we've thought through how Bridgy would handle federated PDSes, right? Maybe we punt on those for now and say use Bridgy Fed for them instead? |
The issue with Rkeys/TIDs is that they're unique per repository, which is to say, per user. Might need some more thought. Federated PDSes I don't know - my impression was that the AT protocol somehow would map a DID back to where that repo actually lives but I can't think how that would actually work. Prob best to park it for now as you say! I have a hunch that the pace of movement towards actual federation in Bluesky will be glacial. |
Hmm true. Unique per repo is fine for Bridgy's usage in URLs, since those are all per user, but not as datastore keys. I can look at that a bit closer later today. Otherwise yeah agreed on Bluesky federation in general. The DID doc itself for a given user points to that users PDS's host. If/when we want Bridgy classic to handle all that, we can, but definitely not necessary now, hard coding bsky.app is totally fine. |
Thanks! For now I’m leaning slightly towards trying to just get AT URIs
working at least for the short term, pending a possible rethink of how keys
and URLs are related to one another.
Would you object to an additional set of endpoints which take query
parameters instead of path parameters, and have the URL generation create
these for Bluesky? This feels like the simplest path to getting something
functional and if we decide to move to something else we can just continue
to redirect them on the server side anyway, no harm really done, they’ll
use the same handler.
…On Sun, 23 Jul 2023 at 00:15, Ryan Barrett ***@***.***> wrote:
Hmm true. Unique per repo is fine for Bridgy's usage in URLs, since those
are all per user, but not as datastore keys. I can look at that a bit
closer later today.
Otherwise yeah agreed on Bluesky federation in general. The DID doc itself
for a given user points to that users PDS's host. If/when we want Bridgy
classic to handle all that, we can, but definitely not necessary now, hard
coding bsky.app is totally fine.
—
Reply to this email directly, view it on GitHub
<#1453 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAVDELESJKQLQOPIOGNR7X3XRRNJNANCNFSM6AAAAAAW2UHCMQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hmm! It's hard to change post ids after launch, since they're stored in |
Oh and again this is awesome progress. Thank you so much! Tons of people threaten to contribute, very few actually do, and even fewer manage to do anything this substantial. |
Managed to get them encoded for the regular paths, they need double-encoded because werkzeug (I think?) decodes them once, but the slashes still break Flask's path matching somehow. I've added a little overrideable method to the Bridgy Source class which formats stuff for URLs and is a no-op for everything else. Here's what I have working, as best I can tell:
I can't test 100% if the webmentions actually work, because webmentions.io can't reach localhost, but the URL sent is correct and does resolve locally, e.g. in here: https://webmention.io/www.joelotter.com/webmention/LFiNzptZ9IUaUt6Hw1a- There are bound to be edge cases that aren't handled properly - for example I really haven't dug into the reply-to handling logic and don't know if I need to do anything specific there - but I think this is now good enough to get out into a PR. Thanks for all your help so far! I've had a lot of fun writing Python for the first time since...2014, wow. |
Awesome! Really great to hear. You navigated a lot to get it to this point, I'm psyched to see the code! Any chance you've looked at writing tests yet? They don't have to be hugely involved, usually there's not a ton of logic in Bridgy source classes, but generally I like at least basic coverage in Bridgy and granary. (Never quite got into them in oauth-dropins, it's more UI and external heavy and less easy to test, but I should eventually bite the bullet and figure them out there too.) |
I’ve not written tests yet, but fully intend to iterate on that once it’s
out in PR. I think the tricky thing, which I might need help with, will be
getting CI builds to pass when there are cross repo dependencies. Is it
sufficient to just change it temporarily to my own repo in the
requirements.txt?
|
Thanks, and true! Bridgy CI clones granary and oauth-dropins at head, granary does the same with oauth-dropins, so I'm fine with PRs on downstream repos failing CI until we get the upstream PRs in, and then we check that downstream goes green before we merge. This ^ does mean that iterating tests on CI doesn't work with cross-repo changes, and it's slow anyway, so definitely get the tests running locally if you can! |
Fair enough! I'll get some PRs out in the meantime and start getting tests together |
@JoelOtter shipped this! Woo, congrats, exciting! Firing up my account, here we go... https://brid.gy/bluesky/did:plc:fdme4gb7mu7zrie7peay7tst |
Woo, it's working! Lots of example webmentions backfed from Bluesky on https://snarfed.org/2023-10-06_bridgy-fed-status-update-7#comment-2868110 |
Exciting! I just connected my site but it looks like it's not finding my bluesky posts. I marked up my posts with a syndication URL that has the |
@aaronpk oh interesting! Yeah it currently expects https://bsky.app/... synd URLs, not at://. We could definitely look into adding those too though! |
Successfully connected my site, and it is seeing both my posts and interactions, but I am getting "[No webmention targets]". I have my Bluesky profile linked on my site and I have my site linked on my Bluesky profile, so not sure what's up. Bridgy works great for my Mastodon account. Great work on this feature! Really excited to see the ever-expanding support in Bridgy 💪 |
Hey @cleverdevil, thanks, good to hear from you! Looks like your posts on https://cleverdevil.io/content/statusupdates/ all have |
Oh, right, I remember that I did use |
Okay, I made a quick change that performs the transformation server-side, and now everything is working great. There are older posts that aren't yet picking up the webmention targets, but I am guessing it will catch up eventually, and posts going forward should backfeed just fine. Thanks again for the hard work, @JoelOtter! |
Lots of follow-up issues filed, but I think we can close this one out. Huge congrats and thanks @JoelOtter!!! |
Both backfeed and publish. I don't plan to do this myself, I'm working on adding Bluesky to Bridgy Fed instead, but I'd be happy to review and merge PRs here.
Granary already has data conversion support, but not API support. Straightforward to add using lexrpc, but we probably want to wait until they add OAuth bluesky-social/atproto#649, I don't want to ask for passwords.
The text was updated successfully, but these errors were encountered: