automatically run received events through the filters they should pass (double-check the work made by the relay).

This commit is contained in:
fiatjaf
2021-12-14 22:00:42 -03:00
parent cd7ffb8911
commit fff31b5ff4
2 changed files with 8 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "nostr-tools", "name": "nostr-tools",
"version": "0.10.0", "version": "0.10.1",
"description": "Tools for making a Nostr client.", "description": "Tools for making a Nostr client.",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@@ -1,6 +1,7 @@
import 'websocket-polyfill' import 'websocket-polyfill'
import {verifySignature} from './event' import {verifySignature} from './event'
import {matchFilters} from './filter'
export function normalizeRelayURL(url) { export function normalizeRelayURL(url) {
let [host, ...qs] = url.split('?') let [host, ...qs] = url.split('?')
@@ -88,10 +89,12 @@ export function relayConnect(url, onNotice) {
let channel = data[1] let channel = data[1]
let event = data[2] let event = data[2]
if (await verifySignature(event)) { if (
if (channels[channel]) { (await verifySignature(event)) &&
channels[channel](event) channels[channel] &&
} matchFilters(openSubs[channel], event)
) {
channels[channel](event)
} }
return return
} }