From b07c056ee5088afc74a994615e72d7f0f30b1293 Mon Sep 17 00:00:00 2001 From: Tony Yang Date: Tue, 15 Apr 2025 10:40:53 +0800 Subject: [PATCH] update: lower message length limit --- functions/api/messages.js | 9 +++++---- src/components/Board/BoardForm.vue | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/functions/api/messages.js b/functions/api/messages.js index b8c5dba..4c53e44 100644 --- a/functions/api/messages.js +++ b/functions/api/messages.js @@ -28,10 +28,11 @@ export async function onRequestPost(context) { const { message } = await request.json(); if (!message) { - return new Response(JSON.stringify({"error": "Missing message"}), { - status: 400, - headers: { 'Content-Type': 'application/json' }, - }); + return createErrorResponse("Empty message", 400); + } + + if (message.length > 200) { + return createErrorResponse("Message too long", 400); } // Generate a unique ID for the message diff --git a/src/components/Board/BoardForm.vue b/src/components/Board/BoardForm.vue index 3f02cdd..facc270 100644 --- a/src/components/Board/BoardForm.vue +++ b/src/components/Board/BoardForm.vue @@ -5,7 +5,7 @@ const emit = defineEmits(['new-message']); const props = defineProps(['locked']); const text = ref(''); -const maxLength = 1024; +const maxLength = 200; const remainingCharacters = computed(() => { return maxLength - text.value.length;