Reblog of Matthias Pfefferle: Enable Mastodon Apps

Reblog via Matthias Pfefferle

Ich war am Wochenende auf dem CloudFest Hackathon und hatte zum zweiten Mal die Change ein Projekt zu betreuen. Die Idee zu „Enable Mastodon Apps“ stammt von @alex und ich freue mich sehr, dass er mir sein „Baby“ für den Hackathon anvertraut hat!

Hier ist unser Pitch:

Hier klicken, um den Inhalt von YouTube anzuzeigen.
Erfahre mehr in der Datenschutzerklärung von YouTube.

var _oembed_068c0c63330a5645737b81421ea55b3e = ‘{“embed”:”<iframe title="Enable Mastodon Apps for WordPress and its Plugins" width="900" height="506" src="https:\/\/www.youtube-nocookie.com\/embed\/VJWdzeZz-ok?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen><\/iframe>”}’;
[data-embed-id=”oembed_068c0c63330a5645737b81421ea55b3e”] { aspect-ratio: 900/506; }.embed-youtube .embed-privacy-logo { background-image: url(https://notiz.blog/wp-content/plugins/embed-privacy/assets/images/embed-youtube.png?v=1698874221); }

Ich bin begeistert von der Idee!

Das Nachbauen der Mastodon-API stellt eine relativ einfache Lösung für das aktuelle ‚App-Problem‘ von WordPress dar. Die gängigen Apps zielen darauf ab, den Nutzern das traditionelle Bloggen zu ermöglichen. Allerdings haben soziale Medien im Allgemeinen und Twitter im Speziellen, die Art und Weise wie wir im Internet kommunizieren, maßgeblich verändert. Es geht nicht mehr um lange Artikel, sondern um kurze Nachrichten ohne Titel mit dem Fokus auf Bilder oder Videos.

Ein weiterer Nebeneffekt sind die sozialen Interaktionen wie Kommentieren (die WordPress über die letzten Jahre spärlich vernachlässigt hat), Liken, Boosten und Bookmarken (die WordPress nativ gar nicht unterstützt), welche die Mastodon Apps von Haus aus schon mit bringen.

„Enable Mastodon Apps“ stellt aber nur die Endpunkte für diese Interaktionen bereit, um sie nutzen zu können, braucht es weitere Plugins, wie z.B. Friends und/oder ActivityPub. Mehr dazu hier: Friends with ActivityPub – Deine nachhaltige Identität im Web.

Das Projekt hat mich sehr an die frühen Twitter-Jahre erinnert. Die Twitter-API galt lange als der de-facto Standard für Micro-blogging und Automattic/@photomatt hat damals schon die Vorteile für sich erkannt und die API für WordPress.com nach gebaut:

Of course one of the coolest things about Twitter right now is the client applications, particularly the mobile/iPhone ones. I use Tweetie 2 on my iPhone every day. Wouldn’t it be cool if you could get all your blog subscriptions and post to your WordPress.com blog from apps like Tweetie? Well here’s an early Christmas present…

We’ve enabled posting to and reading of WordPress.com blogs via the Twitter API. Any app that allows you to set a custom API URL will work.

Post and Read via Twitter API

Hackathon

Wir waren zwar nur 4 Personen, aber ich sag nur „Qualität statt Quantität“!

Vielen Dank @Drivingralle, @matze und @obenland, es war super produktiv und hat großen Spaß gemacht 🙂

Von links nach rechts: Ralf Wiechers, ich, Matthias Kittsteiner und Konstantin Obenland

Was wir erreicht haben:

  • Die meisten Mastodon-API-Endpunkte wurden implementiert.
  • „Hooks“ und „Actions“ für den internen Gebrauch.
  • Dokumentation aller Hooks.
  • Grundlegende Beispielimplementierungen in ActivityPub und im Friends Plugin.
  • Testen von zusätzlichen Clients.

Und hier ein paar Statistiken von den zweieinhalb Tagen:

  • 3 new contributors to the plugin
  • 4,101 lines added
  • 911 lines removed
  • 213 commits
  • 34 files changed
  • 25 PRs merged
  • 7 PRs almost merged
  • 0 Social Media posts

Und hier der Pull Request in seiner ganzen Pracht: Collection of changes from the CloudFest Hackathon

Vielen Dank auch an @bart und das Team von Mammoth, die uns im Vorfeld unterstützt haben. Mammoth funktioniert jetzt wunderbar mit WordPress und Alex und ich hatten einen Einblick in die App-Entwicklung und deren Eigenheiten 🙂

Hier ein paar Bilder:

Mastodon API Tester

tldr: Use the Mastodon API Tester to play with the Client API of Mastodon.

I’ve created the WordPress plugin called Enable Mastodon Apps which does a seemingly small but powerful thing: it enables you to access your WordPress blog using Mastodon apps like Tusky or Ivory. This can be used to browse your own blog and post to it. If you also have the Friends plugin and the ActivityPub plugin installed, this will actually make your WordPress blog behave like a Mastodon instance.

It does this be re-implementing the Mastodon API (unfortunately, Mastodon didn’t opt to implement the ActivityPub client-server API so this is not based on a standard) which can be tricky: it uses REST API endpoints in the (virtual) directories /oauth and /api which are so generic that they are prone to conflicts.

Additionally, although the API is well documented, many apps were created based on assumptions that are true for Mastodon itself (which caused a lot–sometimes hard to reproduce–of issues for the plugin). For example, the id of a post or a user is defined as a string but many apps crash when you put a non-number there. Or that a boosted toot needs to have a different id than the virtual “wrapping” toot (Ivory!). In such cases, apps would crash but work fine with Mastodon itself.

Even more complicated are interactions with other WordPress plugins. It can be hard to understand if the plugin is working correctly, if another plugin is interfering, the hosting provider acts quirky, or if the Mastodon app has an incompatibilty with my implementation.

Thus I have created a simple one-page JS app called Mastodon API Tester hosted on Github pages (source on Github):

I hope that this tool will help identify issues better in future, it can also be used with GotoSocial or a “real” Mastodon instance. Feel free to report issues you might encounter.

PS: the Enable Mastodon Apps plugin will be worked on at the Cloudfest Hackathon, thanks Matthias Pfefferle for taking the lead on this! (Unfortunately, I cannot make it there because I’ll be speaking at WordCamp Asia in Taipei just the weekend before that.)

PPS: Happy Birthday, Matt!