-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add administrative webhooks #18510
Add administrative webhooks #18510
Conversation
10d190e
to
2ffb811
Compare
2ffb811
to
a4298da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me overall, though I made some minor inline comments.
The list of implemented events is pretty limited, but there is no issue with that being extended in subsequent PRs.
def call(*) | ||
raise NotImplementedError | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just code quality, as I see it, defining the role of BaseService
more clearly...
sidekiq_options queue: 'push', retry: 16, dead: false | ||
|
||
def perform(webhook_id, body) | ||
@webhook = Webhook.find(webhook_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use find_by
or catch ActiveRecord::RecordNotFound
?
Brainstormed additional events:
Other points of interest
|
* Add administrative webhooks * Fix error when webhook is deleted before delivery worker runs
I tried to get it to work with the Webhook-functionality provided by t2boit.io - in order to get notifications into a matrix-room. |
If you wanted to make webhooks and stumbled upon this PR, since this is undocumented:
|
* Add administrative webhooks * Fix error when webhook is deleted before delivery worker runs
Is there a facility to reference objects like report number from a webhook? |
This lacking documentation was an expected head scratcher for a moment. For the benefit of anyone else coming to this page and scratching their heads, here's how we go it working for 1) Create the new webhook endpoint on Mattermost2) Create the new webhook event on MastodonFor our needs, we only wanted it triggered for the 3) Change the "Payload Template" of the Mastodon webhook event to:
While you can refer to the Reports API JSON schema for some of the individual variables you are looking for (https://docs.joinmastodon.org/methods/reports/), we set up a listener to view the raw data ourselves and here is the (heavily redacted / fluffed) data received:
For our case, we wanted the following message in the Mattermost channel on each new report: To achieve that, we use the fields
Hope this was helpful for someone to get started with at least! |
@Gargron is there also an event for when a mod leaves a note on the report? Perhaps Alternatively, are there plans for any incoming webhooks so that moderation could be done from a third party site/service (for example, in our case we would want to add a moderator note to the report from inside a Mattermost channel)? |
|
Webhooks would benefit automation through the moderation API by notifying applications about system events in real-time. They would also enable integrations with chat apps like Discord, IRC and Slack, helping moderator coordination.
Events currently supported:
report.created
account.created
The
X-Hub-Signature
header adopted from the WebSub spec can be optionally used to verify that the payloads are authentic.The payload delivered to the webhook has the form of:
Mind that
created_at
at the top-level refers to the event itself, and not theobject
.This project was funded through the NGI0 Discovery Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 825322.