diff --git a/src/policies/pubkey-ban-policy.ts b/src/policies/pubkey-ban-policy.ts index c8bba10..0f60e44 100644 --- a/src/policies/pubkey-ban-policy.ts +++ b/src/policies/pubkey-ban-policy.ts @@ -5,23 +5,16 @@ import { Policy } from '../types.ts'; * Pass an array of pubkeys or an iterable, making it efficient to load pubkeys from a large file. */ const pubkeyBanPolicy: Policy> = ({ event: { id, pubkey } }, pubkeys = []) => { - let isMatch = false; - for (const p of pubkeys) { if (p === pubkey) { - isMatch = true; - break; + return { + id, + action: 'reject', + msg: 'blocked: pubkey is banned.', + }; } } - if (isMatch) { - return { - id, - action: 'reject', - msg: 'blocked: pubkey is banned.', - }; - } - return { id, action: 'accept', diff --git a/src/policies/whitelist-policy.ts b/src/policies/whitelist-policy.ts index f7bbaa8..c08dc71 100644 --- a/src/policies/whitelist-policy.ts +++ b/src/policies/whitelist-policy.ts @@ -5,23 +5,16 @@ import type { Policy } from '../types.ts'; * Pass an array of pubkeys or an iterable, making it efficient to load pubkeys from a large file. */ const whitelistPolicy: Policy> = ({ event: { id, pubkey } }, pubkeys = []) => { - let isMatch = false; - for (const p of pubkeys) { if (p === pubkey) { - isMatch = true; - break; + return { + id, + action: 'accept', + msg: '', + }; } } - if (isMatch) { - return { - id, - action: 'accept', - msg: '', - }; - } - return { id, action: 'reject',