db/events: don't return `author` unless it exists
This commit is contained in:
parent
a6947441fc
commit
f50a78f978
|
@ -200,26 +200,31 @@ async function getFilters<K extends number>(
|
||||||
query = query.limit(opts.limit);
|
query = query.limit(opts.limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (await query.execute()).map((row) => ({
|
return (await query.execute()).map((row) => {
|
||||||
|
const event: DittoEvent<K> = {
|
||||||
id: row.id,
|
id: row.id,
|
||||||
kind: row.kind,
|
kind: row.kind as K,
|
||||||
pubkey: row.pubkey,
|
pubkey: row.pubkey,
|
||||||
content: row.content,
|
content: row.content,
|
||||||
created_at: row.created_at,
|
created_at: row.created_at,
|
||||||
tags: JSON.parse(row.tags),
|
tags: JSON.parse(row.tags),
|
||||||
author: row.author_id
|
sig: row.sig,
|
||||||
? {
|
};
|
||||||
|
|
||||||
|
if (row.author_id) {
|
||||||
|
event.author = {
|
||||||
id: row.author_id,
|
id: row.author_id,
|
||||||
kind: row.author_kind!,
|
kind: row.author_kind! as 0,
|
||||||
pubkey: row.author_pubkey!,
|
pubkey: row.author_pubkey!,
|
||||||
content: row.author_content!,
|
content: row.author_content!,
|
||||||
created_at: row.author_created_at!,
|
created_at: row.author_created_at!,
|
||||||
tags: JSON.parse(row.author_tags!),
|
tags: JSON.parse(row.author_tags!),
|
||||||
sig: row.author_sig!,
|
sig: row.author_sig!,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
: undefined,
|
|
||||||
sig: row.sig,
|
return event;
|
||||||
} as DittoEvent<K>));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Delete events based on filters from the database. */
|
/** Delete events based on filters from the database. */
|
||||||
|
|
Loading…
Reference in New Issue