How PieFed federates “flair” on posts and comments

On the surface flair on PieFed functions very similar to how it does on Reddit – on posts they’re community-specific tags that can be used to filter posts in a community. People can also add flair to themselves which is just a piece of text that appears next to their name whenever they make posts or comments in the community. This can be helpful for giving a hint about someone’s background, interests or expertise.

However PieFed is federated and there are copies of the communities on multiple servers (instances). The way to use ActivityPub to create and maintain those copies is described in FEP 1b12 which makes no mention of flair. I have made some minimal additions to that FEP, described below:

For flair on posts, the Lemmy devs have already done quite a bit of work on this, which I added a little to, so that flair can have colors. Community actors have an additional type of tag:

{
"type": "Group",
"id": "https://piefed.social/c/piefed_meta",
"name": "piefed_meta",
/* ... */
"lemmy:tagsForPosts": [
{
"type": "lemmy:CommunityTag",
"id": "https://piefed.socia1/c/piefed_meta/tag/whatever",
"display_name": "Some Post Tag Name",
"text_color": "#000000",
"background_color": "#dedede"
}
]
}

lemmy:tagsForPosts is a list of lemmy:CommunityTag objects.

So now all the different copies of the community will know which flair can be used there. When creating a post in the community we just need to add one or more lemmy:CommunityTag objects to the Page activity:

{
"id": "https://piefed.social/post/1",
"actor": "https://piefed.social/u/rimu",
"type": "Page",
/* ... */
"tag": [
{
"type": "lemmy:CommunityTag",
"id": "https://piefed.social/c/piefed_meta/tag/whatever",
"display_name": "Some Post Tag Name"
},
{
"href": "https://piefed.social/post/1",
"name": "asdf",
"type": "Hashtag"
}
]
}

In this example the post also has a hashtag on it.

User flair is simpler because it’s not managed by the community moderators and is not a fixed list. PieFed simply adds the author’s flair to every comment (federated as a Note activity) they make. When a Note is received the author’s flair is updated on the receiving instances.

{
"id": "https://piefed.social/comment/1",
"actor": "https://piefed.social/u/rimu",
"type": "Note",
/* ... */
"flair": "PieFed dev"
}

This means that when someone changes their flair it will take effect immediately on their instance but until they write a comment it won’t propagate to other instances. As flair is primarily used on comments and the people using flair will tend to be posting a lot of comments this is kinda “good enough”.

It would be trivial to add a “flair” attribute onto posts too and have receiving instances read that. User flair shows up next to the author’s name on their posts so arguably it makes sense to send it then too.

Let’s see how it goes.

Leave a Reply

Your email address will not be published. Required fields are marked *