feat(faceit): add webhook-triggered synchronization - #19
Draft
gouveags wants to merge 1 commit into
Draft
Conversation
Collaborator
Author
|
@greptileai review |
Collaborator
Author
|
CI follow-up:
I am leaving that existing frontend-performance work out of this draft so the webhook/security change stays narrowly scoped. No deployment was attempted. |
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.
Summary
Automatic FACEIT updates currently depend only on periodic polling, which either wastes requests or leaves long stale windows. This proposal adds an authenticated webhook wake-up path while keeping the existing database-backed worker as the sole owner of canonical FACEIT synchronization and retaining scheduled reconciliation as a fallback.
This PR is intentionally a draft. Before it becomes merge-ready, a real FACEIT App Studio delivery must be captured, redacted, and added as a fixture to confirm that its championship identifier matches the Data API championship ID used by Ace.
Problem
The current scheduler updates active championships frequently even when no match is live, while a lower fixed frequency could miss match transitions. FACEIT webhooks can accelerate meaningful changes, but accepting external payloads directly would create authentication, payload-trust, duplicate-delivery, concurrency, and observability risks.
Changes
src/app/api/webhooks/faceit/route.tsandsrc/lib/faceit-webhook.tsPOST /api/webhooks/faceitcallback protected by a minimum-32-byte shared header secret and fixed-length timing-safe digest comparison.204for unlinked or unmappable events.src/lib/faceit-championship-sync.tsPrisma and admin UI
/admin/faceitalongside the existing automatic synchronization health state.Configuration and operations
FACEIT_WEBHOOK_SECRET, the callback/header configuration, the narrow Organizer event list, verification steps, and the real-payload fixture gate.How to test
npm run db:generate,npm run db:migrate, andnpm run db:migrate:statusagainst a clean SQLite database.npm run test:faceit-webhookand verify authentication, body limits, payload isolation, linked-record isolation, disabled/terminal behavior, reordered deliveries, and adaptive scheduling pass.npm run test:faceit-syncand verify a webhook arriving during a FACEIT fetch remains immediately due after that fetch commits.npm run check,npm audit --audit-level=high, andnpm run build.202and updates Último webhook.Deployment note
Do not configure the FACEIT App Studio subscription yet. If this proposal is eventually approved, deploy the code and migration first, set a freshly generated
FACEIT_WEBHOOK_SECRETon the server, restart the application, and only then configure the callback and shared header in App Studio. Scheduled reconciliation continues working if the secret or subscription is absent.Draft blockers
payload.entity.idis the same championship UUID used by/data/v4/championships/{id}.