Merge branch 'nip20' into 'develop'
Return proper NIP-20 responses See merge request soapbox-pub/strfry-policies!5
This commit is contained in:
commit
ba482e5dfb
@ -14,7 +14,7 @@ Deno.test('passes events through multiple policies', async () => {
|
||||
]);
|
||||
|
||||
assertEquals(result.action, 'reject');
|
||||
assertEquals(result.msg, 'The relay is read-only.');
|
||||
assertEquals(result.msg, 'blocked: the relay is read-only');
|
||||
});
|
||||
|
||||
Deno.test('short-circuits on the first reject', async () => {
|
||||
@ -26,7 +26,7 @@ Deno.test('short-circuits on the first reject', async () => {
|
||||
]);
|
||||
|
||||
assertEquals(result.action, 'reject');
|
||||
assertEquals(result.msg, 'The relay is read-only.');
|
||||
assertEquals(result.msg, 'blocked: the relay is read-only');
|
||||
});
|
||||
|
||||
Deno.test('accepts when all policies accept', async () => {
|
||||
|
@ -16,7 +16,7 @@ const hellthreadPolicy: Policy<Hellthread> = (msg, opts) => {
|
||||
return {
|
||||
id: msg.event.id,
|
||||
action: 'reject',
|
||||
msg: `Event rejected due to ${p.length} "p" tags (${limit} is the limit).`,
|
||||
msg: `blocked: rejected due to ${p.length} "p" tags (${limit} is the limit).`,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ const keywordPolicy: Policy<Iterable<string>> = ({ event: { id, content } }, wor
|
||||
return {
|
||||
id,
|
||||
action: 'reject',
|
||||
msg: 'Event contains a banned word or phrase.',
|
||||
msg: 'blocked: contains a banned word or phrase.',
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ const pubkeyBanPolicy: Policy<Iterable<string>> = ({ event: { id, pubkey } }, pu
|
||||
return {
|
||||
id,
|
||||
action: 'reject',
|
||||
msg: 'Pubkey is banned.',
|
||||
msg: 'blocked: pubkey is banned.',
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ const rateLimitPolicy: Policy<RateLimit> = async (msg, opts) => {
|
||||
return {
|
||||
id: msg.event.id,
|
||||
action: 'reject',
|
||||
msg: 'Rate-limited.',
|
||||
msg: 'rate-limited: too many requests',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import type { Policy } from '../types.ts';
|
||||
const readOnlyPolicy: Policy<void> = (msg) => ({
|
||||
id: msg.event.id,
|
||||
action: 'reject',
|
||||
msg: 'The relay is read-only.',
|
||||
msg: 'blocked: the relay is read-only',
|
||||
});
|
||||
|
||||
export default readOnlyPolicy;
|
||||
|
@ -8,7 +8,7 @@ const regexPolicy: Policy<RegExp> = ({ event: { id, content } }, regex) => {
|
||||
return {
|
||||
id,
|
||||
action: 'reject',
|
||||
msg: 'Event matches a banned expression.',
|
||||
msg: 'blocked: text matches a banned expression.',
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ const whitelistPolicy: Policy<Iterable<string>> = ({ event: { id, pubkey } }, pu
|
||||
return {
|
||||
id,
|
||||
action: 'reject',
|
||||
msg: 'Only certain pubkeys are allowed.',
|
||||
msg: 'blocked: only certain pubkeys are allowed to post',
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user