diff --git a/src/storages/events-db.ts b/src/storages/events-db.ts index 025b503..4467e37 100644 --- a/src/storages/events-db.ts +++ b/src/storages/events-db.ts @@ -68,6 +68,7 @@ class EventsDB implements EventStore { /** Insert an event (and its tags) into the database. */ async add(event: NostrEvent): Promise { + event = cloneEvent(event); this.#debug('EVENT', JSON.stringify(event)); if (isDittoInternalKind(event.kind) && event.pubkey !== Conf.pubkey) { @@ -408,6 +409,19 @@ function buildSearchContent(event: NostrEvent): string { } } +/** Return a normalized event without any non-standard keys. */ +function cloneEvent(event: NostrEvent): NostrEvent { + return { + id: event.id, + pubkey: event.pubkey, + kind: event.kind, + content: event.content, + tags: event.tags, + sig: event.sig, + created_at: event.created_at, + }; +} + /** Build search content for a user. */ function buildUserSearchContent(event: NostrEvent): string { const { name, nip05, about } = jsonMetaContentSchema.parse(event.content);