Merge branch 'nip20' into 'develop'

Return proper NIP-20 responses

See merge request soapbox-pub/strfry-policies!5
This commit is contained in:
Alex Gleason 2023-03-28 23:57:30 +00:00
commit ba482e5dfb
8 changed files with 9 additions and 9 deletions

View File

@ -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 () => {

View File

@ -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).`,
};
}
}

View File

@ -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.',
};
}

View File

@ -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.',
};
}

View File

@ -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',
};
}
}

View File

@ -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;

View File

@ -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.',
};
}

View File

@ -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',
};
};