EventsDB: normalize the event to only NIP-01 event properties
This commit is contained in:
parent
aaf01462c1
commit
0b6874bb44
|
@ -68,6 +68,7 @@ class EventsDB implements EventStore {
|
||||||
|
|
||||||
/** Insert an event (and its tags) into the database. */
|
/** Insert an event (and its tags) into the database. */
|
||||||
async add(event: NostrEvent): Promise<void> {
|
async add(event: NostrEvent): Promise<void> {
|
||||||
|
event = cloneEvent(event);
|
||||||
this.#debug('EVENT', JSON.stringify(event));
|
this.#debug('EVENT', JSON.stringify(event));
|
||||||
|
|
||||||
if (isDittoInternalKind(event.kind) && event.pubkey !== Conf.pubkey) {
|
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. */
|
/** Build search content for a user. */
|
||||||
function buildUserSearchContent(event: NostrEvent): string {
|
function buildUserSearchContent(event: NostrEvent): string {
|
||||||
const { name, nip05, about } = jsonMetaContentSchema.parse(event.content);
|
const { name, nip05, about } = jsonMetaContentSchema.parse(event.content);
|
||||||
|
|
Loading…
Reference in New Issue