feat(webhooks): add webhook event dispatcher (#998) - #1145
Merged
Akanimoh12 merged 1 commit intoJul 30, 2026
Merged
Conversation
Fans a domain event (e.g. tip.received) out to every ACTIVE, non-deleted webhook subscription owned by the relevant user that is registered for it: records a PENDING WebhookDelivery per match and enqueues a signed HTTP delivery job via the existing webhook-delivery queue. One subscription failing to enqueue never blocks the others. Closes Akanimoh12#998
|
@DSOTec Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Akanimoh12
merged commit Jul 30, 2026
128e29e
into
Akanimoh12:test-implement-drips
4 of 5 checks passed
Owner
|
Great implementation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The webhooks module already has subscription CRUD (#997), a delivery log endpoint (#1001), and a BullMQ delivery worker with HMAC signing + retries (#993/#1000). What's missing is the piece connecting the two: something that, when a domain event happens (e.g.
tip.received), looks up the matching subscriptions and actually creates/enqueues a delivery. Without it, noWebhookDeliveryrows are ever created and no HTTP delivery is ever triggered.Solution
Adds
dispatchWebhookEvent(ownerId, event, data)inbackend/src/modules/webhooks/webhooks.dispatcher.ts:ACTIVE, non-deletedWebhookSubscriptions owned byownerIdthat are registered for the given event type.PENDINGWebhookDeliveryrow per match.{ event, timestamp, data }, seedocs/WEBHOOKS.md) and hands it to the existingscheduleWebhookDeliveryqueue, which signs the payload (HMAC-SHA256) and delivers with retries — that path is untouched.Promise.allSettled).Also exports a
WebhookEventTypetype fromwebhooks.schema.tsandWebhookEventEnvelope/WebhookDispatchResulttypes fromwebhooks.types.tsfor use by callers.Follow-up (out of scope here): delivery status (
SUCCESS/FAILED) is not yet reconciled back onto theWebhookDeliveryrow after the HTTP call completes — that lives in the retry-policy worker (jobs/webhookDelivery.ts, #1000) and touching it felt like a separate, riskier change on an actively-changing branch. Rows are created asPENDINGand the delivery itself is signed/sent/retried correctly; only the row's final status isn't updated yet.Testing
npx eslint src/modules/webhooks/*.ts— clean.npm run typecheck— no new errors (repo has 4 pre-existing errors in an unrelatednotifications.test.tsparse issue on this branch already, untouched by this PR).npx vitest run src/modules/webhooks— 28/28 pass (23 existing + 5 new).npm run test(full suite) — same pre-existing failures as before this change (tests requiring a live Postgres instance I didn't have running locally), no new failures, 5 more passing than baseline.Closes #998