From fff31b5ff40d74192774584a901fe0b29a37c16d Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Tue, 14 Dec 2021 22:00:42 -0300 Subject: [PATCH] automatically run received events through the filters they should pass (double-check the work made by the relay). --- package.json | 2 +- relay.js | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index aabba53..870569c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nostr-tools", - "version": "0.10.0", + "version": "0.10.1", "description": "Tools for making a Nostr client.", "repository": { "type": "git", diff --git a/relay.js b/relay.js index 88f4ec5..b174d3b 100644 --- a/relay.js +++ b/relay.js @@ -1,6 +1,7 @@ import 'websocket-polyfill' import {verifySignature} from './event' +import {matchFilters} from './filter' export function normalizeRelayURL(url) { let [host, ...qs] = url.split('?') @@ -88,10 +89,12 @@ export function relayConnect(url, onNotice) { let channel = data[1] let event = data[2] - if (await verifySignature(event)) { - if (channels[channel]) { - channels[channel](event) - } + if ( + (await verifySignature(event)) && + channels[channel] && + matchFilters(openSubs[channel], event) + ) { + channels[channel](event) } return }