db/events: fix catching UNIQUE violations

This commit is contained in:
Alex Gleason 2023-10-11 16:24:10 -05:00
parent 451b77d6c4
commit 5cb87a0fd9
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 2 additions and 2 deletions

View File

@ -1,5 +1,5 @@
import { db } from '@/db.ts';
import { type Event, SqliteError } from '@/deps.ts';
import { type Event } from '@/deps.ts';
import { isParameterizedReplaceableKind } from '@/kinds.ts';
import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
import { EventData } from '@/types.ts';
@ -64,7 +64,7 @@ function insertEvent(event: Event, data: EventData): Promise<void> {
]);
}).catch((error) => {
// Don't throw for duplicate events.
if (error instanceof SqliteError && error.code === 19) {
if (error.message.includes('UNIQUE constraint failed')) {
return;
} else {
throw error;