ActivityPub Outbox and Webmentions

When you have both ActivityPub and Webmentions plugins installed, every post or reply you create in WordPress is sent as both an ActivityPub activity and a Webmention ping, which happened to my reply to this blog post about his awesome Daymark plugin:

Reply to an ActivityPub post as a comment on a WordPress site

I posted the reply using my FediTap web app that posts via the new ActivityPub API in the ActivityPub plugin, which means that:

  1. ActivityPub received my reply from FediTap over REST API.
  2. ActivityPub turned the object.inReplyTo into a activitypub/reply block and placed it at the top of the post content.
  3. ActivityPub sent the reply to Jeff’s ActivityPub inbox which published it as a comment on the post.
  4. Webmentions plugin scheduled a one-time cron job to send a webmention ping as well.

When Jeff’s site received the messages:

  1. ActivityPub processed the incoming Create activity as a comment on that object.inReplyTo post, stored the reply object ID in source_id and the public URL of it in source_url comment meta.
  2. Webmention processed the incoming HTTP payload, matched source_url with webmention’s source and replaced the comment body with it’s own version that includes the URL from the activitypub/reply block at the top.

I’m not sure if this is the desired behavior.

You can use the following snippet to disable the Webmention pings for posts that are also replies to ActivityPub objects:

add_action( 'activitypub_outbox_created_post', function ( $post_id, $activity ) {
    if ( ! empty( $activity['object']['inReplyTo'] ) ) {
        update_post_meta( $post_id, 'webmentions_disabled_pings', true );
    }
}, 10, 2 );

We must set the post meta because the webmention processing happen asynchronously on cron so it has to be persisted.

Leave a Reply

Reply on Mastodon or search for ️this permalink in your ActivityPub client, and it will show up here too (also follow this blog). Or simply leave a comment below: