db/events: fix catching UNIQUE violations
This commit is contained in:
parent
451b77d6c4
commit
5cb87a0fd9
|
@ -1,5 +1,5 @@
|
||||||
import { db } from '@/db.ts';
|
import { db } from '@/db.ts';
|
||||||
import { type Event, SqliteError } from '@/deps.ts';
|
import { type Event } from '@/deps.ts';
|
||||||
import { isParameterizedReplaceableKind } from '@/kinds.ts';
|
import { isParameterizedReplaceableKind } from '@/kinds.ts';
|
||||||
import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
|
import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
|
||||||
import { EventData } from '@/types.ts';
|
import { EventData } from '@/types.ts';
|
||||||
|
@ -64,7 +64,7 @@ function insertEvent(event: Event, data: EventData): Promise<void> {
|
||||||
]);
|
]);
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
// Don't throw for duplicate events.
|
// Don't throw for duplicate events.
|
||||||
if (error instanceof SqliteError && error.code === 19) {
|
if (error.message.includes('UNIQUE constraint failed')) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
throw error;
|
throw error;
|
||||||
|
|
Loading…
Reference in New Issue