pipeline: move created_at check up
This commit is contained in:
parent
594be870e1
commit
ec6b72229c
|
@ -28,6 +28,10 @@ const debug = Debug('ditto:pipeline');
|
||||||
* It is idempotent, so it can be called multiple times for the same event.
|
* It is idempotent, so it can be called multiple times for the same event.
|
||||||
*/
|
*/
|
||||||
async function handleEvent(event: DittoEvent, signal: AbortSignal): Promise<void> {
|
async function handleEvent(event: DittoEvent, signal: AbortSignal): Promise<void> {
|
||||||
|
// 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 (!(await verifyEventWorker(event))) return;
|
||||||
if (encounterEvent(event)) return;
|
if (encounterEvent(event)) return;
|
||||||
debug(`NostrEvent<${event.kind}> ${event.id}`);
|
debug(`NostrEvent<${event.kind}> ${event.id}`);
|
||||||
|
@ -115,11 +119,6 @@ async function storeEvent(event: DittoEvent, signal?: AbortSignal): Promise<void
|
||||||
const store = await Storages.db();
|
const store = await Storages.db();
|
||||||
const kysely = await DittoDB.getInstance();
|
const kysely = await DittoDB.getInstance();
|
||||||
|
|
||||||
// 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');
|
|
||||||
}
|
|
||||||
|
|
||||||
await updateStats({ event, store, kysely }).catch(debug);
|
await updateStats({ event, store, kysely }).catch(debug);
|
||||||
await store.event(event, { signal });
|
await store.event(event, { signal });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue