Comments via Mastodon

In May 2019 I removed Disqus from this site simply because it had turned into an ad-network. Not wanting to “own” other people’s comments also didn’t replace it with something custom made/self-hosted. About a year later I had stumbled upon webmentions and started implementing it here using the webmentiond project. Nearly exactly a year after removing Disqus webmentiond supported comments and I embedded them below my blogposts.

When I read Carl Schwan’s post about embedding Mastodon comments directly using the Mastodon API back in December I knew I want to have that too! He solved this by fetching comments client-side via JavaScript but I wanted to have a little more control over what is shown on my blog.

Frustrated with the world I set out to solve that problem for me yesterday. A couple of hours later I had a rough implementation deployed on my website:

Similar to webmentiond there is now another service called “retoots” running on my server. When I have a post that should allow commenting via Mastodon, there is a small JavaScript embedded in that post that fetches replies to a status linked to this blog post from retoots.

retoots, in turn, then contacts the Mastodon server that status is stored at and fetch all descendants through its API, normalises the data a little bit, and then returns that to the blog for rendering. This has the advantage that I can, in the future, add some content filtering (e.g. not rendering posts by known spammers etc.) and also some caching so that comments are also shown if the Mastodon server is down.

From a privacy point of view this also means that readers of my blog won’t contact a third-party Mastodon server directly and therefore their IPs and other metadata won’t show up in the access logs there but just on my own server.

You can find the current state of retoots on GitHub. At this point it’s mostly a proof of concept with very limited documentation and not even proper releases. If everything works out that will change, though, in the near future 😀

You can also find this post linked to from the following pages: