I'm Luke Johnson

I live and work in Vancouver, BC
I write about research and other interests here


Fediverse usability: Lemmy/Mbin/PieFed communities on Mastodon

Back in the day, I used to spend a lot of time on Reddit. I still skim through the top posts on certain subreddits from time to time, but the site has now been sliding down the inevitable and crudely-named ensh*ttification spiral for some time. As with most social media platforms, there are alternatives on the Fediverse: platforms like Lemmy, Mbin and PieFed. These are formatted like Reddit: each page has a list of posts ordered using an algorithm that takes into account both recency and popularity (based on upvotes and downvotes). Clicking on each post will take you to that post’s comments, arranged in a similar way.

A screenshot of https://programming.dev/c/linux@lemmy.ml

Posts on the Linux community of programming.dev, a Lemmy-based server.

Because these are based on the ActivityPub protocol, like Mastodon, you can view and interact with posts there from your Mastodon account, as has been tested by others before. This is handy for somebody like me—I don’t like to have too many accounts to pay attention to at once, and above a certain critical mass I end up unconciously abandoning some (my apologies to the fine people on the BC Urbanists Discord channel).

A mess of replies

Here’s the trouble though: interacting with Lemmy communities (or Mbin magazines, or Piefed… slices?) from Mastodon is clunky at best. Mastodon treats these communities as “groups”, which reblog (boost) every post and comment from the community in reverse chronological order. This translation from a forum-style layout to a microblog feed leaves you with a mess of mostly context-free replies with some posts sprinkled in—almost impossible to browse meaningfully.1

This problem is holding back both platforms. Mastodon users are missing out on some great posts and discussions in these communities, and Lemmy/Mbin/Piefed etc (I’m just going to start calling them LemBinFed from now on) communities would become more active if it were easier for Mastodon users to add to the discussion in the comments. Until Mastodon distinguishes between posts and comments from LemBinFed, there needs to be a different way to only show top-level posts in your Mastodon feed.

A super simple bot

After a quick search, I decided to make my own hacky solution in the form of a basic Python-based bot script to be run as an automated Mastodon account. I used this example by Lambdanaut on Github as a starting point, switching out the list of hashtags to follow with a list of LemBinFed communities, and adding some extra code to filter top-level posts from replies. Here’s how it works:

  1. The bot follows one or more LemBinFed communities.
  2. Every few minutes, it looks through all of the new posts on its home feed.
  3. For each post, it checks whether that post was a reply or not.
  4. If the post isn’t a reply (a top-level post), it boosts it.
  5. That’s all!

In a little more detail, the magnificent if statement in step 3 that decides whether or not to boost a certain post looks like this:

if status.reblog.in_reply_to_id is None and \
    not "comment" in status.reblog.url and \
    not status.reblog.reblogged and \
    status.account.acct != account.acct and \
    status.reblog.account.acct != account.acct and \
    status.reblog.account.acct not in config.IGNORE_AUTHORS and \
    domain not in config.IGNORE_SERVERS:

    # Boost the status

status is the post our bot reads on its Mastodon timeline, so status.reblog is the original post on Lemmy. in_reply_to_id fetches the ID of any parent status, so we want this to be None to exclude replies. However sometimes the Mastodon API is unable to fetch a reply’s parent even if it does exist (e.g. if the user or server is blocked), so some replies still slip through. These are then caught by the next line, because every comment on LemBinFed contains the word “comment” in its URL! status.reblog.reblogged checks whether the bot has already boosted that post, and the remaining lines make sure the bot doesn’t self-boost and ignores posts from a pre-specified list of accounts and servers. Clear as mud, right?

Clear enough for me, anyway. Because this is such a simple concept, using only Python and the Mastodon API, I’m absolutely sure somebody has thought of this before. It can’t be that easy, right?

You’re right, it can’t

So there I was, confident that everything was working nicely. I’d set up a couple of test bots, one of which was supposed to follow the Linux communities on lemmy.ml, lemmy.world and programming.dev. However, I soon noticed I was only getting boosts of the last one.

Turns out, this is because of another pointless interoperability problem between Mastodon and Lemmy. You see, Lemmy communities have URLs formatted like this lemmy.site/c/communityname and can be searched with !communityname@lemmy.site. Lemmy users have URLs formatted like this lemmy.site/u/username and can be searched using @username@lemmy.site. A user can have the same name as a community, no problem, because they’re addressed differently. Can you see where this is going?

Both Mastodon users and groups have URLs like this mastodon.site/@groupname or mastodon.site/@username, and are addressed like this @groupname@mastodon.site or @username@mastodon.site.

So if you were to search for a Lemmy community but there was also a Lemmy user with the same name, Mastodon would only return the user. Come on, people!

So yeah, I’m going to leave this here for now. However, I do have an idea for how to move forward (spoilers, it involves RSS—the venerable protocol holding up about half of the Internet). See you in part 2!


  1. Normally you can filter replies out of your home feed on Mastodon, but this doesn’t affect boosts of replies. Which is a problem, because the “group” boosts posts and replies indiscriminately. ↩︎

Comments

You can use your Mastodon or other Fediverse account to comment on this post by replying to this thread.

Alternatively, you can reply to this Bluesky thread using a bridged Bluesky account.

Learn how this is implemented here.