Goodbye Mastodon. Hello Fediverse.

As of today, this site is also my canonical social media presence!

Notes on making this happen:

I’m using the ActivityPub and Webfinger plugins to make WordPress users into full-fledged Fediverse citizens.

I had a lot of trouble getting Mastodon to recognize this site as a valid target for an account move. Mastodon demands some not-so-standardized stuff to appear on the target site that effectively makes its vaunted “account mobility” only work with other Mastodon instances 🧐

First off I had to disable caching for user profile pages. To be fair this part wasn’t a Mastodon issue. I’m going to come back around later and see if I can re-introduce caching more in content-type-aware way.

Then I had to use hooks to hack up the webfinger responses and activity stream page to add alias and alsoKnownAs properties, respectively, to my old Hachyderm Mastodon account.

add_filter('webfinger_user_resources', 'avdicodes_add_hachyderm_mastodon_alias', 1, 2);
function avdicodes_add_hachyderm_mastodon_alias($resources, $user) {
    if('avdi' === $user->user_login) {
        $resources[] = 'https://hachyderm.io/@avdi';
        $resources[] = 'https://hachyderm.io/users/avdi';
        $resources[] = 'acct:avdi@hachyderm.io';
    }
    return $resources;
}

add_filter('activitypub_activity_user_object_array', 'avdicodes_add_aka_to_activity_stream', 10, 3);
function avdicodes_add_aka_to_activity_stream($array, $object_id, $object) {
    $user_login = get_userdata($object->get__id())->user_login;
    if('avdi' === $user_login) {
        $array['alsoKnownAs'] = ['https://hachyderm.io/users/avdi'];
    }
    return $array;
}

That last filter was by far the trickiest part. Some of these Mastodon expectations are undocumented other than the Mastodon codebase. I wound up running Mastodon locally and putting it under the debugger to figure out what was missing.

Eventually I got it working though, and here we are. Feel free to leave reply – it should appear as a comment on my blog!

8 comments

  1. @avdi Hey, first, thanks for sharing it, also, I have a question, is this bi-directional? can you follow people from your instance and there is a timeline there?

    1. Actually I stand corrected, I installed the Friends plugin and now I can follow people. With the Mastodon API plugin I can even use Mastodon clients to interact!

Comments are closed.