From 4940bbd481be09c2c09ffbd5a0c48664d75cd797 Mon Sep 17 00:00:00 2001 From: Brian Lee Date: Tue, 9 Jan 2024 08:51:32 -0800 Subject: [PATCH] size-limit-policy: Exclude replaceable and epheremal kinds, drop default to 8Kb. --- src/policies/size-limit-policy.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/policies/size-limit-policy.ts b/src/policies/size-limit-policy.ts index 182f4b3..21c6b32 100644 --- a/src/policies/size-limit-policy.ts +++ b/src/policies/size-limit-policy.ts @@ -28,15 +28,11 @@ const sizeLimitPolicy: Policy = ({ 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`, }; }