diff --git a/src/pipeline.ts b/src/pipeline.ts index 3255aa7..c85cc0b 100644 --- a/src/pipeline.ts +++ b/src/pipeline.ts @@ -35,6 +35,7 @@ async function handleEvent(event: DittoEvent, signal: AbortSignal): Promise ${event.id}`); if (event.kind !== 24133) { @@ -84,6 +85,13 @@ function encounterEvent(event: NostrEvent): boolean { return encountered; } +/** Check if the event already exists in the database. */ +async function existsInDB(event: DittoEvent): Promise { + const store = await Storages.db(); + const events = await store.query([{ ids: [event.id], limit: 1 }]); + return events.length > 0; +} + /** Hydrate the event with the user, if applicable. */ async function hydrateEvent(event: DittoEvent, signal: AbortSignal): Promise { await hydrateEvents({ events: [event], store: await Storages.db(), signal });