diff --git a/src/pipeline.ts b/src/pipeline.ts index 81e9b5e..e62bd03 100644 --- a/src/pipeline.ts +++ b/src/pipeline.ts @@ -28,6 +28,10 @@ const debug = Debug('ditto:pipeline'); * It is idempotent, so it can be called multiple times for the same event. */ async function handleEvent(event: DittoEvent, signal: AbortSignal): Promise { + // Integer max value for Postgres. TODO: switch to a bigint in 2038. + if (event.created_at >= 2_147_483_647) { + throw new RelayError('blocked', 'event too far in the future'); + } if (!(await verifyEventWorker(event))) return; if (encounterEvent(event)) return; debug(`NostrEvent<${event.kind}> ${event.id}`); @@ -115,11 +119,6 @@ async function storeEvent(event: DittoEvent, signal?: AbortSignal): Promise= 2_147_483_647) { - throw new RelayError('blocked', 'event too far in the future'); - } - await updateStats({ event, store, kysely }).catch(debug); await store.event(event, { signal }); }