Skip to content

Commit

Permalink
nostr-tools being randomly throw error in their own code. Put safety.
Browse files Browse the repository at this point in the history
Signed-off-by: Yonle <yonle@lecturify.net>
  • Loading branch information
Yonle committed Apr 15, 2024
1 parent b0e7e76 commit 1c20de4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion bouncer.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,15 @@ function getIdleSess(ws) {
newsess();
}

function _matchFilters(filters, event) {
// nostr-tools being randomly throw error in their own code. Put safety.
try {
return matchFilters(filters, event);
} catch {
return false;
}
}

// WS - Sessions
function newConn(addr, id, reconn_t = 0) {
if (!csess.has(id)) return;
Expand Down Expand Up @@ -328,7 +337,7 @@ function newConn(addr, id, reconn_t = 0) {
if (client.rejectKinds && client.rejectKinds.includes(data[2]?.id)) return;

const filters = client.subs.get(data[1]);
if (!matchFilters(filters, data[2])) return;
if (!_matchFilters(filters, data[2])) return;

const NotInSearchQuery = "search" in filter && !data[2]?.content?.toLowerCase().includes(filter.search.toLowerCase());
if (NotInSearchQuery) return;
Expand Down

0 comments on commit 1c20de4

Please sign in to comment.