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
|
// Convert the content into bytes and check its size
|
||||||
const contentSize = new TextEncoder().encode(content).length;
|
const contentSize = new TextEncoder().encode(content).length;
|
||||||
|
|
||||||
if (contentSize > maxContentSize && !excludeKinds.includes(kind)) {
|
if (contentSize > maxContentSize && !excludeKinds.includes(kind) && kind < 10000) {
|
||||||
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 });
|
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
action: 'reject',
|
action: 'reject',
|
||||||
msg: `blocked: message is too large.`,
|
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