From 935cc7c5a574ba9bf5cb148a14f4f0db3a932377 Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Fri, 13 Sep 2024 14:33:34 -0300 Subject: [PATCH] refactor: remove NIP-50 search if looking for accounts, use same filter --- src/controllers/api/search.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/controllers/api/search.ts b/src/controllers/api/search.ts index 19e72cac..1a1bd867 100644 --- a/src/controllers/api/search.ts +++ b/src/controllers/api/search.ts @@ -91,21 +91,18 @@ async function searchEvents({ q, type, limit, account_id }: SearchQuery, signal: filter.authors = [account_id]; } - const filter2: NostrFilter = { - kinds: [0], - limit, - }; if (type === 'accounts') { const kysely = await Storages.kysely(); const pubkeys = await getPubkeysBySearch(kysely, { q, limit }); - filter2.authors = pubkeys; // if pubkeys is empty the filter 2 will be discarded + filter.authors = pubkeys; + filter.search = undefined; } const store = await Storages.search(); - return store.query([filter, filter2], { signal }) + return store.query([filter], { signal }) .then((events) => hydrateEvents({ events, store, signal })); }