Improve stupid code
This commit is contained in:
parent
566df31b4a
commit
48501f3c5f
@ -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<Iterable<string>> = ({ 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',
|
||||
|
@ -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<Iterable<string>> = ({ 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',
|
||||
|
Loading…
Reference in New Issue
Block a user