Improve stupid code
This commit is contained in:
parent
566df31b4a
commit
48501f3c5f
@ -5,22 +5,15 @@ import { Policy } from '../types.ts';
|
|||||||
* Pass an array of pubkeys or an iterable, making it efficient to load pubkeys from a large file.
|
* 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 = []) => {
|
const pubkeyBanPolicy: Policy<Iterable<string>> = ({ event: { id, pubkey } }, pubkeys = []) => {
|
||||||
let isMatch = false;
|
|
||||||
|
|
||||||
for (const p of pubkeys) {
|
for (const p of pubkeys) {
|
||||||
if (p === pubkey) {
|
if (p === pubkey) {
|
||||||
isMatch = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isMatch) {
|
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
action: 'reject',
|
action: 'reject',
|
||||||
msg: 'blocked: pubkey is banned.',
|
msg: 'blocked: pubkey is banned.',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
|
@ -5,22 +5,15 @@ import type { Policy } from '../types.ts';
|
|||||||
* Pass an array of pubkeys or an iterable, making it efficient to load pubkeys from a large file.
|
* 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 = []) => {
|
const whitelistPolicy: Policy<Iterable<string>> = ({ event: { id, pubkey } }, pubkeys = []) => {
|
||||||
let isMatch = false;
|
|
||||||
|
|
||||||
for (const p of pubkeys) {
|
for (const p of pubkeys) {
|
||||||
if (p === pubkey) {
|
if (p === pubkey) {
|
||||||
isMatch = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isMatch) {
|
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
action: 'accept',
|
action: 'accept',
|
||||||
msg: '',
|
msg: '',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
|
Loading…
Reference in New Issue
Block a user