Building Slack integration

This commit is contained in:
KS Jannette
2026-08-02 06:13:01 -04:00
parent dae256f6c6
commit b607ee9121
16 changed files with 2351 additions and 8 deletions

View File

@@ -96,7 +96,10 @@ router.post('/:provider', async (req: Request, res: Response, next: NextFunction
enqueue(`${slug}:${delivery.externalId}`, async () => {
await markProcessing(eventId);
try {
await createNotes(notes);
const enriched = config.enrich
? await config.enrich(delivery, payload)
: delivery;
await createNotes(enriched.notes);
await markDone(eventId);
} catch (err) {
await markFailed(eventId, err instanceof Error ? err.message : String(err));
@@ -104,7 +107,12 @@ router.post('/:provider', async (req: Request, res: Response, next: NextFunction
}
});
res.status(200).json({ accepted: true, notes: notes.length });
// The count is omitted for providers that enrich, because enrichment runs
// after this response and may drop notes whose content cannot be fetched.
// No number is better than one that is sometimes wrong.
res.status(200).json(
config.enrich ? { accepted: true } : { accepted: true, notes: notes.length }
);
} catch (err) {
next(err);
}