From 6d0c7c796f3c05a8b6c05dd11d74c3ed651e1c9d Mon Sep 17 00:00:00 2001 From: Jonathan Staab Date: Tue, 11 Jul 2023 13:15:52 -0700 Subject: [PATCH] Re-apply filter when fetching events --- ROADMAP.md | 8 +------- src/system/network.ts | 6 ++++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 3304dab9..7a6ab230 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,18 +1,12 @@ # Current -- Cmd -> EventBuilder -- Create new "command" module that wraps event builder + outbox + any local anonymous state -- Move getUserRelays, getUserMutes etc back to user module? - - [ ] Refactor - - [ ] Move system initialization to app/system - [ ] Delete messages when leaving a room - [ ] Add pagination to chat/dms - [ ] Fix scrolling to to when modal is open - - [ ] Take connection health into account when building hints - - [ ] Re-apply filter to get rid of unwanted events - [ ] Test migration - [ ] Improve watchers so users of system don't need to know how they work + - [ ] Remove external dependencies - [ ] Check for TODOs - [ ] Add custom emoji support - [ ] Re-work note media diff --git a/src/system/network.ts b/src/system/network.ts index 2696a29a..5ed2f83a 100644 --- a/src/system/network.ts +++ b/src/system/network.ts @@ -1,7 +1,7 @@ import type {Filter} from "nostr-tools" import type {MyEvent} from "src/util/types" import {EventEmitter} from "events" -import {verifySignature} from "nostr-tools" +import {verifySignature, matchFilters} from "nostr-tools" import {Pool, Plex, Relays, Executor, Socket} from "paravel" import {ensurePlural} from "hurdak/lib/hurdak" import {union, difference} from "src/util/misc" @@ -212,7 +212,9 @@ export class Network extends EventEmitter { return } - // TODO: validate that the event we asked for matches the filters we sent + if (!matchFilters(filters, event)) { + return + } this.emit("event", {url, event})