From a4f9985f2cd3de297e0baa41d0b1ca5ae69ce528 Mon Sep 17 00:00:00 2001 From: BlowaterNostr Date: Mon, 8 Apr 2024 15:46:14 +0800 Subject: [PATCH] fix --- test.ts | 6 +++++- ws.ts | 24 ++++++++++++------------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/test.ts b/test.ts index c40cc49..d94a7fe 100644 --- a/test.ts +++ b/test.ts @@ -13,7 +13,10 @@ import { SingleRelayConnection, SubscriptionStream, } from "./_libs.ts"; -import { limit } from "https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/relay-single-test.ts"; +import { + limit, + no_event, +} from "https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/relay-single-test.ts"; const test_kv = async () => { try { @@ -139,6 +142,7 @@ Deno.test("main", async (t) => { await t.step("nip1", async () => { await limit(relay.url)(); + await no_event(relay.url)(); }); await client.close(); diff --git a/ws.ts b/ws.ts index 46d77da..7aab4dc 100644 --- a/ws.ts +++ b/ws.ts @@ -227,6 +227,17 @@ async function handle_filter(args: { event_candidates.set(event.id, event); } } + if (filter.authors) { + if (event_candidates.size > 0) { + console.log("event_candidates", event_candidates); + } else { + const events = args.get_events_by_authors(new Set(filter.authors)); + for await (const event of events) { + console.log(event); + event_candidates.set(event.id, event); + } + } + } if (filter.kinds) { if (event_candidates.size > 0) { const keys = Array.from(event_candidates.keys()); @@ -237,7 +248,7 @@ async function handle_filter(args: { } event_candidates.delete(key); } - } else { + } else if (!filter.authors) { const events = get_events_by_kinds(new Set(filter.kinds)); for await (const event of events) { console.log(event); @@ -245,17 +256,6 @@ async function handle_filter(args: { } } } - if (filter.authors) { - if (event_candidates.size > 0) { - console.log("event_candidates", event_candidates); - } else { - const events = args.get_events_by_authors(new Set(filter.authors)); - for await (const event of events) { - console.log(event); - event_candidates.set(event.id, event); - } - } - } if (filter.limit) { for await (const event of args.get_events_by_filter(filter)) { event_candidates.set(event.id, event);