Note that unless you’re a Lemmy instance admin, this doesn’t have much use to you.
Until this package came along, if you wanted a bot that responds to events, you had to manually traverse all comments/posts/whatever at a fixed interval. With this package you can actually react to events directly from the database. It’s implemented in a very efficient way by connecting the package directly to the Lemmy database and using native Postgres features to get the events (LISTEN/NOTIFY if you want to get technical).
The webhooks themselves are inserted into a separate SQLite database (API is coming) and allow for both simple and complex filtering of the incoming data. The system is already in use by two of my bots, @[email protected] and @[email protected] who now both receive the information about being tagged in a comment in seconds (the actual reply takes a little longer, but that’s because of the nature of the bot).
Currently you can be notified about a post or a comment, other types are trivial to include as well.
Let me know what you think!
Oh I see, thanks. I was imagining this being used by bot authors who don’t want to run actual lemmy instances. This makes sense now, given that you want to run your bots on Lambda. I’d just run them on a VM but that’s just me. Cloudflare Workers seems like another possibility.
It’s not only for the Lambda use case, my main motivation was AutoMods - they are very resource intensive currently and need to run very often. What you needed to do until this package, was traversing all new posts and all comments in there to check whether they’re newer than the last post / comment you’ve moderated. Which is a lot of api requests every minute or two, you’re essentially DDOSing yourself. With this, your AutoMod receives the information that a new comment was created and you can fetch the comment in a single (relatively inexpensive) api request, instead of plethora of requests which are all fairly expensive.
Whether the webhooks feature is then exposed to other users is really up to each instance admins, I’m thinking of exposing the functionality for my instance’s users when I finish implementing all I have envisioned.
Of course bot authors can add support for webhook triggering which means the admins can then use it more effectively.
I see, that is a good application. How did Reddit deal with this issue? Lemmy does lots of dumb things by comparison it seems to me. I’d be surprised if reddit required constant polling from automods.
No idea, I didn’t do any api development with Reddit, it felt way too oversaturated already. But event subscriptions are a common thing for such use-cases, so my guess would be actually very similar to what I have created here with this package.
Fair enough, but it sounds like the subscription feature should really be built into Lemmy’s API. That is, your package is a useful workaround for a shortcoming in Lemmy. It’s probably worth fixing Lemmy directly