Enforce a created_at max value

This commit is contained in:
Alex Gleason 2024-05-29 18:25:18 -05:00
parent 1ad1808ee2
commit 60b762a165
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 5 additions and 0 deletions

View File

@ -115,6 +115,11 @@ async function storeEvent(event: DittoEvent, signal?: AbortSignal): Promise<void
const store = await Storages.db();
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 store.event(event, { signal });
}