Skip Navigation

Threativore now provides a REST API

With threativore 0.8.x I have finally released a feature I've been planning for a while, the ability to maintain and view it via REST API.

The first thing that is released in the REST API is the ability to see a user's information, which at the moment contains the user's profile ID, their threativore roles and the newest fields, which is tags for users

 undefined
    
{
  "user_url": "https://lemmy.dbzer0.com/u/db0",
  "roles": [
    "UserRoleTypes.MODERATOR",
    "UserRoleTypes.ADMIN"
  ],
  "tags": [
    {
      "tag": "ko-fi_tier",
      "value": "deck hand",
      "flair": "https://lemmy.dbzer0.com/pictrs/image/0cc8915a-acf8-451b-8350-c889f469ac42.webp",
      "expires": "2025-03-15 13:18:46.305405",
      "description": "This user is donating a moderate amount to their instance through Ko-Fi"
    },
    {
      "tag": "pirate",
      "value": "true",
      "flair": "https://lemmy.dbzer0.com/pictrs/image/156d1970-0600-4bea-b3d2-53435be3c314.webp",
      "expires": null,
      "description": "This user likes pirates"
    },
    {
      "tag": "anarchist",
      "value": "true",
      "flair": "https://lemmy.dbzer0.com/pictrs/image/61a552e5-d1db-43a5-a120-f584e3082c2d.webp",
      "expires": null,
      "description": "This user likes anarchism"
    },
    {
      "tag": "foss",
      "value": "true",
      "flair": "https://lemmy.dbzer0.com/pictrs/image/00ac9132-cecd-41e6-ba81-8ffd51043bdd.webp",
      "expires": "2025-01-14 13:07:57.467910",
      "description": "This user likes free software"
    },
    {
      "tag": "liberapay_tier",
      "value": "powder monkey",
      "flair": null,
      "expires": "2025-03-16 20:05:57.525031",
      "description": "This user is donating a moderate amount to their instance through Liberapay"
    }
  ]
}

  

The tags are free-form and any threativore admin can assign any tags to any users with whatever values. For example one of my plan in lemmy.dbzer0.com is to add a boolean tag for pirate if the user mentioned a pirate in their application form, or alternatively anarchist or FOSS respectively. Likewise I have automated adding tags based on whether someone has donated to the site through ko-fi recently and at which tier.

Currently these tags don't have any effect, but I want to bring together the various frontend developers, such as @ptz@dubvee.org from tesseract, @sheodox@lemmy.world from alexandrite, @aeharding@vger.social and so on to see if we can come up with a standard where we can specify within threativore how the tags could be utilized. Or perhaps agree for a standard location where the threativore can always be sought by UIs to retrieve info (as it's not part of the lemmy API proper)

For example I can arrange for a new field per tag, which would contain an emoji code, or an image url, which would be displayed by the UI as flavor for that user. I want to provide ways for each instance to be more unique, (until and if lemmy itself adds such functionality in the backend).

Another functionality which is not immediately obvious is that I now added code to allow threativore to reach in directly to the lemmy DB and extract any data needed. This is for example how lemmy.dbzer0.com can match users on ko-fi with users in lemmy. I plan to extend this functionality in the future to hopefully provide more ways for threativore to detect and deal threats, even without info publicly available in the API.

With all this I want to make threativore a valuable companion software to lemmy, to provide a lot more extensibility through the UIs and empower instance admins to do even more for the looks and security of their instances.

If you want to deploy threativore, I provide a simply code chunk you can add to your lemmy UI in docker-compose. You can even disable the anti-spam capabilities if you want (although they don't do anything until you populate them), and just keep it as an API only.

Let me know what you think.

9 comments
  • I'm not against it and think it could provide a cool bit of polish/personalization, but I've got a few sticky points about implementing it:

    1. I haven't had a chance to look at the API yet, but at first glance I'm not sure how I'd implement it without having to do a remote call for every post/comment that is returned.

    In the feed, that would be anywhere from 10-30 API calls in rapid succession (depending on the configured number of posts per fetch and how many of those are by the same user). On a post, it could be up to 150 or more (depending on how many unique commenters are active in the comment section).

    I could definitely proxy/cache those requests server-side as with Fediseer, but I'd have to basically write an API that talks to your API. Doable, just not a priority on the current sprint.

    The only thing I can think of that would address that would be if there was a daily JSON export that Tesseract could poll for. It could pull that JSON periodically (every 24 hours) and use it as the lookup file rather than making a double-hop API call (client -> tess server -> threadivore). That's basically how my MBFC integration works.

    1. I have no idea where I'd put them lol.

    The UserLink component is probably the most widely-used component in the whole app. Every time you see a username, it's rendering through that component. Getting it to behave, squish, stretch, truncate, and not overflow its bounding is already something of a nightmare. That's probably the next major component I'm going to re-write now that I've paid off the tech debt on the post render pipeline.

    I basically design for mobile first and then tweak for desktop, so even though there's plenty of room on desktop, at the minimum, I would have to hide any custom flairs on mobile.

    However, as-is, It may be possible to integrate it into the user cards, though. Those are only loaded on-demand and have more space available. Those just aren't as visible as they would be if they showed up alongside the username in posts/comments.

    • Thanks for checking.

      For the api it wouldn't be a heavy load to fetch individual users 150 times or whatever if that's your concern, but if you prefer not to, I will deploy a full user list export. However as usage expands this could grow prohibitive large. There's already 10k users in there with at least 1 tag each.

      I feel that doing a fetch on demand and caching it locally for a couple of hours is probably more efficient. I don't see the need for a proxy service but I'm not proficient with web dev so I might be missing smt.

      For the placement, I was thinking of just one flair icon next to the avatar, and the others being visible in the user card as you mentioned. Would an extra icon really be too much? There's some empty space I see between the username and the timestamp (on mobile). But even just on desktop size, it would be cool.

  • Maybe you already know this, and it wasn't your intention, but those Mentions in the post body won't page the relevant people - it only works if they're in a comment.

  • Threativore updated to v0.9. Now each tag can specify an optional flair string and an optional expiry date. The flair string should either be an emoji unicode, or a link to an image. The expectation then is that lemmy UIs will display that flair next to the username in some fashion

  • Would the tags be visible to everybody or is it meant to serve like an admin only note taking system?

9 comments