janboddez / indieblocks

Use blocks, and, optionally, "short-form" post types to more easily "IndieWebify" your WordPress site.
https://indieblocks.xyz
GNU General Public License v3.0
22 stars 3 forks source link

ActivityPub integration? #194

Closed janboddez closed 1 month ago

janboddez commented 2 months ago

So, https://github.com/janboddez/addon-for-activitypub already adds ActivityPub support. I mean, turn "IndieBlocks likes" into "actual" ActivityPub likes, etc. Similar to "Webmention likes."

But maybe we could add like, reply, and repost integration right into this plugin.

Since all of it depends on in-post content (rather than custom fields, tags, etc.), we wouldn't need to work around Gutenberg's transition_post_status and post meta quirks.

Also, the other add-on does rely on php-mf2 to store ActivityPub URL and actor data in a custom field on save, and then works around those quirks when sending.

If we were to add this functionality to IndieBlocks, we probably should avoid all that and just parse the blocks on each request. Which adds a slight overhead but much less than running php-mf2 and not too much in comparison with what we're already doing (and WordPress itself is doing).

janboddez commented 2 months ago

Ah, parse_blocks doesn't work with our blocks? Or rather, while innerblocks are returned, the "attribute/selector" attributes (i.e., those read from HTML) aren't. If we'd instead store them in a "JSON comment" attribute (but why would we do that, we don't have to) it'd work ...

janboddez commented 2 months ago

See https://github.com/WordPress/gutenberg/issues/46029#issuecomment-1326330988 for a possible solution. Should work for reading the href. Otherwise DOMDocument ... or php-mf2. But those are slow ...

janboddez commented 2 months ago

Made a first start: https://github.com/janboddez/indieblocks/blob/main/includes/class-activitypub-compat.php. Doesn't yet do mentions (notifications), and trimming off the reply context is super hacky, but it's something.

janboddez commented 1 month ago

Going to port my findings back to the other plugin and keep this functionality there, I think.