feat(webhooks): implement subscription topic filtering (#119)#126
Open
Ebenezer199914 wants to merge 1 commit into
Open
feat(webhooks): implement subscription topic filtering (#119)#126Ebenezer199914 wants to merge 1 commit into
Ebenezer199914 wants to merge 1 commit into
Conversation
## Core Feature — Webhook Subscription Topic Filtering
- Add webhookMatchesTopic() with exact and wildcard (transaction.*) matching
- Export ALLOWED_EVENTS and WILDCARD_TOPICS constants from merchantWebhook model
- Add MerchantWebhookModel.listAvailableTopics() with event descriptions
- Add MerchantWebhookModel.findActiveByUserIdAndTopic() for topic-aware lookup
- Update MerchantWebhookService.dispatchEvent() to use topic-aware fan-out
- Add MerchantWebhookService.listTopics() helper
- Add GET /api/merchant/webhooks/topics route exposing available topics
- Add migration 20260629_webhook_topic_filtering.sql:
- GIN index on merchant_webhooks.events for fast topic queries
- CHECK constraint allowing 'transaction.*' wildcard alongside concrete events
## Bug Fixes
- src/stellar/webhooks.ts: fix memo-based transaction lookup
- text memos fall through to reference-number lookup first, as expected
- findByReferenceNumber return handled as array or single object
- Remove stellar_hash from patchMetadata (not expected by consumers)
- src/routes/webhooks.ts: add setup_url to 500 response when WEBHOOK_SECRET unset
- src/routes/__tests__/webhooks.test.ts: mock TransactionModel + ingestRateLimiter
so tests no longer require a live database/Redis connection
- src/stellar/sep02.ts: restore domain check in lookupByName; fix 'q is required'
error message; remove orphaned return/brace fragment (pre-existing syntax error)
- src/queue/accountMergeWorker.ts: fix capturePersistentFailure call signature
(pass CaptureOptions object instead of raw Job — pre-existing type error)
## Tests
- New: src/services/__tests__/merchantWebhook.topic-filtering.test.ts
- webhookMatchesTopic() exact and wildcard coverage
- ALLOWED_EVENTS / WILDCARD_TOPICS constant assertions
- listAvailableTopics() shape and description completeness
- create/update validation with wildcard acceptance
- findActiveByUserIdAndTopic() filters inactive and non-matching webhooks
- dispatchEvent() topic-aware fan-out and no-match short-circuit
- All 77 webhook tests pass (7 suites, 0 failures)
- All 23 SEP-02 federation tests pass
- TypeScript build clean (0 errors)
|
Hey @Ebenezer199914! 👋 It looks like this PR isn't linked to any issue. If this PR is for one of the issues assigned to you as part of a Wave, please link it to ensure your contribution is tracked properly. You can do this by adding a keyword to the PR description (e.g.,
|
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.
Core Feature — Webhook Subscription Topic Filtering
Bug Fixes
Tests
Description
Brief description of changes.
Related Issue
Fixes #(issue number)
Type of Change
Changes Made
Testing
How did you test these changes?
Checklist
Screenshots (if applicable)
Additional Notes
closes feat(webhooks): implement subscription topic filtering (#119)
#126