snarfed / bridgy-fed

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

support Pixelfed #39

Open snarfed opened 5 years ago

snarfed commented 5 years ago

it does AP, so it might already work! first thing to do is try testing it.

https://pixelfed.org , https://github.com/pixelfed/pixelfed , cc @swentel @dansup.

alternatively we could just lobby for microformats and webmentions. 😄

swentel commented 5 years ago

Yes. I saw it has atom feeds, so that's great for following - would be cooler if it had microformats indeed.

I'm going to open an account and see if I can interact with it already ;-)

swentel commented 5 years ago

Tried it, bummer ;-) I have a post here: https://pixelfed.social/p/swentel/16606 Tried a reply but got stuck on the inbox post request.

Might be because federation hasn't been fully deployed yet when checking their account (https://mastodon.social/@pixelfed/100925207518316311)

dansup commented 5 years ago

@snarfed AP support isn't quite ready yet. I am interested in implementing more indieweb stuff like microformats and maybe webmentions!

swentel commented 5 years ago

Tried another reply as https://mastodon.social/@pixelfed/101301109645686324 says it should work, but didn't get through yet. I'll see if I can trigger it from command line.

swentel commented 5 years ago

So got a bit further already setting up a pixelfed instance on my local machine. When trying to validate the actor, I was sending 'https://fed.brid.gy/r/http://realize.be' but that didn't resolve, using https://fed.brid.gy/realize.be was fine (I didn't have any problems with that testing with mastodon, and bridgy fed sends a full actor object afaics, so that might actually be a problem too).

However, after that, we need some more properties in the actor activity json as pixelfed wants to store following properties on the actor object

Once I faked that, the profile was saved. The username becomes @realize.be@fed.brid.gy - I guess that isn't that much of a problem (I think)

The reply doesn't get through, because when the url is verified, it tries to get the application/ld+json representation of it, unless I'm reading the code wrong (going from handleNoteReply() to statusFirstOrFetch()). It's weird though that it wants to bail out here as it has the activity object already, so I'm a bit in the dark here why it does that. Any pointers @dansup ?

snarfed commented 5 years ago

awesome progress, thank you @swentel! i can definitely add those three properties, and look into why conneg for application/ld+json for the wrapped reply URL isn't working.

snarfed commented 5 years ago

ok @swentel, bridgy fed actors now have summary, outbox, and publicKey.id. example: https://fed.brid.gy/realize.be .

snarfed commented 5 years ago

and re:

The reply doesn't get through, because when the url is verified, it tries to get the application/ld+json representation of it

you mean that pixelfed tries to fetch a bridgy fed wrapped post URL, eg https://fed.brid.gy/r/https://snarfed.org/2018-11-10_30370 , with something like Accept: application/ld+json, which we need to handle and return AS2 instead of the current 302 redirect, right? just checking before i start coding.

swentel commented 5 years ago

Yes, the code for the internal http client uses following headers:

public static function zttpUserAgent()
{               
    return [
        'Accept'     => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
        'User-Agent' => 'PixelFedBot - https://pixelfed.org',
     ];
}

I'm still a bit in the dark why it does that validation again, but I assume that it wouldn't hurt to have this representation anyway. Mastodon does it as well, e.g.

wget --header="Accept: application/ld+json" https://mastodon.technology/@snarfed/100119606571241751
snarfed commented 5 years ago

@swentel done! /r/... URLs now convert to AS2 when asked for it instead of redirecting. example:

curl -v -H 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"' \
  https://fed.brid.gy/r/https://snarfed.org/2018-11-10_30370
swentel commented 5 years ago

Awesome, will test and let you know to see if my local instance accepts it! fingers crossed

swentel commented 5 years ago

So pixelfed assumes attributedTo is a string and not an object. It also makes assumptions on the object received from the AS2 response, and that can never work like we are sending them. So I think replies can never work from other federated platforms, maybe currently only from pixelfed instances.

This is on hold until that's figured out - and fixed in pixelfed imo.

swentel commented 3 years ago

Ok, I got a reply working for pixelfed. You can see the reply on https://pixelfed.social/p/swentel/16606.

This is the object I send.

Array
(
    [type] => Create
    [id] => https://realize.be/activitypub/104
    [actor] => https://realize.be/user/1/activitypub/swentel
    [to] => Array
        (
            [0] => https://www.w3.org/ns/activitystreams#Public
            [1] => https://pixelfed.social/users/swentel
        )

    [object] => Array
        (
            [type] => Note
            [id] => https://realize.be/reply/content/1696
            [attributedTo] => https://realize.be/user/1/activitypub/swentel
            [published] => 2018-12-25T12:09:23Z
            [content] => <p>Wow, what a view!</p>
            [inReplyTo] => https://pixelfed.social/p/swentel/16606
            [to] => Array
                (
                    [0] => https://www.w3.org/ns/activitystreams#Public
                    [1] => https://pixelfed.social/users/swentel
                )

        )

    [@context] => https://www.w3.org/ns/activitystreams
)

Pixelfed validates again by fetching the activitystreams representation of the id in the object (https://realize.be/reply/content/1696 - note: with Accept: application/activity+json). The part which took me long to figure out is that the response of this is not the activity, but only the object

{"type":"Note","id":"https:\/\/realize.be\/reply\/content\/1696","attributedTo":"https:\/\/realize.be\/user\/1\/activitypub\/swentel","published":"2018-12-25T13:09:23Z","content":"\u003Cp\u003EWow, what a view!\u003C\/p\u003E","inReplyTo":"https:\/\/pixelfed.social\/p\/swentel\/16606","to":["https:\/\/www.w3.org\/ns\/activitystreams#Public","https:\/\/pixelfed.social\/users\/swentel"],"@context":"https:\/\/www.w3.org\/ns\/activitystreams"}

I'll come back to confirm that a note with attachment works.

swentel commented 3 years ago

Posting individual notes (photos) works as well. Notes without attachment won't work (unless it's a reply). The important part here is that the attachment needs a 'Type' and 'mediaType' (mime) property. If these are not there, the validation won't work, and the post will not show up. Default valid media types (for type=image) are image/jpeg, image/png and image/gif

Payload example - visible at https://pixelfed.social/i/web/post/_/218345390364299264/219416742496178176 (but you need to be authenticated to view - not exactly sure why that is, that's for another day to figure out)

Array
(
    [type] => Create
    [id] => https://realize.be/activitypub/192
    [actor] => https://realize.be/user/1/activitypub/swentel
    [to] => Array
        (
            [0] => https://www.w3.org/ns/activitystreams#Public
            [1] => https://pixelfed.social/users/swentel
        )

    [object] => Array
        (
            [type] => Note
            [id] => https://realize.be/image/dartmoor
            [attributedTo] => https://realize.be/user/1/activitypub/swentel
            [published] => 2020-03-12T08:27:03Z
            [content] => <p>A magical sunrise with Vixen Tor in the background. Just haven't seen the pixies yet in the forest :)</p>
            [attachment] => Array
                (
                    [0] => stdClass Object
                        (
                            [type] => Image
                            [mediaType] => image/jpeg
                            [url] => https://realize.be/sites/default/files/DJI_0034.JPG
                        )

                )

            [to] => Array
                (
                    [0] => https://www.w3.org/ns/activitystreams#Public
                    [1] => https://pixelfed.social/users/swentel
                )

        )

    [@context] => https://www.w3.org/ns/activitystreams
)
jk-na commented 3 years ago

I tried to reply to a post on my pixelfed instance using bridgy fed and it looks like the job is failing due to the keyId being the incorrect format.

The error at the pixelfed end is: ErrorException: Undefined index: keyId in /usr/share/nginx/html/pixelfed/app/Jobs/InboxPipeline/InboxValidator.php:159

The format of the keyId in the post is: keyId="acct:jk.nipponalba.scot@jk.nipponalba.scot" Whereas on a randomly selected successful job it is in the format: keyId="https://pipou.academy/users/AuroreAcelya#main-key"

snarfed commented 1 year ago

I tried to federate a like of this post on piconic.co, running Pixelfed v0.11.4. It succeeded, BF log here, but I don't see the like on the post yet. 🤷

snarfed commented 1 year ago

I liked the same post from @snarfed@indieweb.social (Mastodon), and that like now shows up on the post, so interop here still isn't quite working yet.

snarfed commented 1 year ago

Another thing to look at: when I search for @snarfed.org@snarfed.org on a PixelFed instance, it finds me, but it shows my handle as @snarfed.org@fed.brid.gy. 😐

snarfed commented 11 months ago

After #442, I tried liking and replying to the same piconic.co post above again, https://piconic.co/i/web/post/507466431055899254 , both 200ed but neither showed up.

snarfed commented 11 months ago

Tried this follow just now, also 200ed and didn't show up.

If BF users' server shows up in PixelFed as fed.brid.gy, not their domain, ie we're eg @snarfed.org@fed.brid.gy, I wonder if that's related. Maybe a signature keyId thing? Should look more.

{
  "published": "2023-10-24T13:01:58-07:00",
  "content": "Follows <a class=\"u-follow-of\" href=\"https://piconic.co/i/web/profile/145384761425268736\">https://piconic.co/i/web/profile/145384761425268736</a>.\n<div class=\"e-content\">\npiconic\n</div>",
  "url": "https://fed.brid.gy/r/https://snarfed.org/2023-10-24_piconic-2",
  "actor": "https://fed.brid.gy/snarfed.org",
  "id": "https://fed.brid.gy/r/https://snarfed.org/2023-10-24_piconic-2",
  "@context": "https://www.w3.org/ns/activitystreams",
  "type": "Follow",
  "object": "https://piconic.co/users/snarfed",
  "to": [
    "https://www.w3.org/ns/activitystreams#Public"
  ],
  "contentMap": {
    "en": "Follows <a class=\"u-follow-of\" href=\"https://piconic.co/i/web/profile/145384761425268736\">https://piconic.co/i/web/profile/145384761425268736</a>.\n<div class=\"e-content\">\npiconic\n</div>"
  }
}
snarfed commented 4 months ago

Follows still aren't getting accepted ^. Eg for @TomCasavant in #1053, we sent the Follow below from actor https://bsky.brid.gy/bsky.brid.gy to https://pixelfed.social/users/mrpresidenttom/inbox at 2024-05-08T10:45:02.854174+00:00, and it returned HTTP 202, but never sent back an Accept, and the follow never registered on pixelfed.social's end.

{
  "id": "https://bsky.brid.gy/r/https://bsky.brid.gy/#follow-back-https://pixelfed.social/users/mrpresidenttom-2024-05-08T10:45:02.854174+00:00",
  "actor": "https://bsky.brid.gy/bsky.brid.gy",
  "@context": "https://www.w3.org/ns/activitystreams",
  "type": "Follow",
  "object": "https://pixelfed.social/users/mrpresidenttom",
  "to": [
    "https://www.w3.org/ns/activitystreams#Public"
  ]
}
snarfed commented 2 weeks ago

Pinged dansup on Matrix just now 🤞

ThisIsMissEm commented 2 weeks ago

@snarfed that object ID doesn't look like a valid URI? Maybe that's the source of the issue?

snarfed commented 2 weeks ago

@ThisIsMissEm thanks for looking! And hmm. https://bsky.brid.gy/r/https://bsky.brid.gy/#follow-back-https://pixelfed.social/users/mrpresidenttom-2024-05-08T10:45:02.854174+00:00 isn't a valid URI? Because of the non-encoded + or :s? Lots of other fediverse software is accepting that id format fine, so I'm guessing it's not the issue here, but I'd be curious to hear more if it actually is invalid somehow.

qazmlp commented 2 weeks ago

@ThisIsMissEm thanks for looking! And hmm. https://bsky.brid.gy/r/https://bsky.brid.gy/#follow-back-https://pixelfed.social/users/mrpresidenttom-2024-05-08T10:45:02.854174+00:00 isn't a valid URI? Because of the non-encoded + or :s? Lots of other fediverse software is accepting that id format fine, so I'm guessing it's not the issue here, but I'd be curious to hear more if it actually is invalid somehow.

The URI is syntactically fine afaict, but maybe it's trying to actually fetch it?

snarfed commented 2 weeks ago

Hmm, maybe? ids with fragment are relatively common in the fediverse, and how to fetch them is largely undefined. 🤷 https://github.com/w3c/activitypub/issues/367

snarfed commented 1 week ago

Pinged dansup on Matrix just now 🤞

No answer, as always 😕