aaronpk / XRay

X-Ray returns structured data from any URL
https://xray.p3k.app
MIT License
90 stars 15 forks source link

Make this work with ActivityPub WordPress plugin #101

Open bekopharm opened 3 years ago

bekopharm commented 3 years ago

The issue is described here: https://github.com/pfefferle/wordpress-activitypub/issues/78 and according to @pfefferle can probably only be solved in XRay: https://github.com/pfefferle/wordpress-activitypub/issues/78#issuecomment-570731802

dshanske commented 1 year ago

@aaronpk I think I thought of a workaround for this. I know it is an extra piece for your code, but how about this?

WordPress sites, even when delivering @pfefferle 's activitypub code, return two standard link headers.

rel="https://api.w.org/" - Which is a link to the WordPress Rest API endpoint rel="alternate"; type="application/json" - Which is a link to the JSON representation of the URL in the Rest API endpoint.

Could you, if you detect this, indicating a WordPress site, refetch the HTML and parse?

aaronpk commented 1 year ago

Ok I've given this some thought and I have a different plan for how to handle it on the XRay side.

XRay is used for a lot of things, one of which being fetching a page to verify a webmention. Given that is it extremely unlikely to receive a webmention from an ActivityPub JSON URL, I'll add an option to XRay so that the caller can say "I'm trying to fetch this page for webmention verification" and that will disable adding the ActivityPub Accept header, since it will never expect to receive ActivityPub JSON when verifying a webmention. That seems to be the cleanest option that should avoid special casing sites.

aaronpk commented 1 year ago

Done in 438430ffc20e02790f67c19b5d080401fc5bc697

Deploying to webmention.io now...

aaronpk commented 1 year ago

Should be live now. Please test and let me know how it goes.