Expand description
Outgoing event webhooks: administration and the events.
Administrators register webhooks (URL, events, optional project group).
The services call emit inside the transaction of the event, which
writes one delivery per matching active webhook into the outbox
webhook_deliveries; crate::webhooks sends them. A rolled back event
leaves no delivery behind.
Every payload has the same envelope – event, id (one per event, the
same for every webhook), occurred_at, actor.username, instance – plus
the objects of the event (revision, change, change_request, …) with
their identifiers, web_url and api_url. File contents and secrets are
never part of a payload.
| Event | Emitted by | Objects |
|---|---|---|
revision.released | the last approval of a change, per revision | revision, change |
revision.obsoleted | marking a released revision obsolete | revision |
change.submitted | submitting a change for review | change, revisions |
change.approved | every approval of a reviewer | change, review, revisions |
change.rejected | a reviewer’s rejection (rejects the change) | change, review, revisions |
change.released | the last approval | change, revisions |
change_request.created | raising a change request | change_request, items |
change_request.decided | accepting, rejecting or deferring a request | change_request, decision |
simulation.result_added | adding or importing simulation result values | revision, result or import |
Structs§
- Delivery
- One entry of the outbox.
- Webhook
- A webhook as shown to administrators – without its secret.
- Webhook
Input - What an administrator enters.
Constants§
- MAX_
WEBHOOKS - Most webhooks of one instance.
- SECRET_
PREFIX - Prefix of generated webhook secrets.
Functions§
- change_
object - A change in a payload.
statusis the status after the event. - create
- Registers a webhook. Returns it and its secret – the only time the secret leaves the server.
- delete
- Deletes a webhook together with its deliveries.
- deliveries
- The latest deliveries of a webhook, newest first.
- emit
- Queues an event for every active webhook that subscribed to it and whose
project group (if any) is one of
projects. Call it inside the event’s transaction. Returns the number of deliveries queued. - get
- get_
delivery - list
- payload
- Builds the payload of an event: the envelope plus
objects(a JSON object whose keys are added at the top level). - request_
object - A change request in a payload (with its current status).
- retry
- Schedules a failed (or waiting) delivery again, now, with a fresh set of attempts. The delivery id stays the same, so receivers can deduplicate.
- revision_
object - A revision in a payload.
stateis the state after the event. - rotate_
secret - Replaces the secret. Returns the webhook and the new secret (shown once). Deliveries that are still pending are signed with the new secret.
- send_
test - Queues a
pingdelivery to an active webhook; returns its id (the caller may send it at once withDispatcher::deliver_now). - update
- Changes name, URL, events, project group and the active flag. Pending deliveries of a webhook that is switched off are given up.