feat: fire webhooks on jetstream events, cap at 10 per DID

- db.ts: getWebhooksByDid returns the 10 most recent subscriptions (ORDER BY id DESC LIMIT 10)
- jetstream.ts: fireWebhooks fans out to registered URLs via Promise.allSettled after each create/update/delete event
This commit is contained in:
Julien Calixte
2026-02-25 22:51:48 +01:00
parent 373b7a6777
commit 62f981dd93
2 changed files with 35 additions and 3 deletions

View File

@@ -92,6 +92,12 @@ export const deleteWebhooksByDid = (did: string): void => {
db.exec("DELETE FROM webhook_subscription WHERE did = ?", did);
};
export const getWebhooksByDid = (did: string): WebhookSubscriptionRow[] => {
return db.prepare(
"SELECT id, did, method, url FROM webhook_subscription WHERE did = ? ORDER BY id DESC LIMIT 10",
).all<WebhookSubscriptionRow>(did);
};
export const upsertNote = (note: Note) => {
const now = new Date().toISOString();
db.exec(