size-limit-policy: Exclude replaceable and epheremal kinds, drop default to 8Kb.
This commit is contained in:
parent
c303045e33
commit
4940bbd481
@ -28,15 +28,11 @@ const sizeLimitPolicy: Policy<SizeLimitOptions> = ({ event: { id, content, kind
|
||||
// Convert the content into bytes and check its size
|
||||
const contentSize = new TextEncoder().encode(content).length;
|
||||
|
||||
if (contentSize > maxContentSize && !excludeKinds.includes(kind)) {
|
||||
const timestamp = new Date().toISOString();
|
||||
const logMessage = `${timestamp}: ID: ${id}, Kind: ${kind} rejected, ${contentSize} > max content size (${maxContentSize})\n`;
|
||||
Deno.writeTextFileSync('./size-limit-policy.log', logMessage, { append: true });
|
||||
if (contentSize > maxContentSize && !excludeKinds.includes(kind) && kind < 10000) {
|
||||
return {
|
||||
id,
|
||||
action: 'reject',
|
||||
msg: `blocked: message is too large.`,
|
||||
//msg: `blocked: ${timestamp}: ID: ${id}, Kind: ${kind} rejected, ${contentSize} > max content size (${maxContentSize})\n`,
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user