From a16246bd0cb5a59fc44d7d48dd3b7da8af5a92f9 Mon Sep 17 00:00:00 2001 From: Wells Bunker Date: Tue, 16 Sep 2025 13:04:38 -0600 Subject: [PATCH] fix slack message max length being reached and set max box rows for input --- apps/server/src/api/v2/support/index.ts | 53 ++++++++++++++++--- .../features/modals/SupportModal.tsx | 2 + 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/apps/server/src/api/v2/support/index.ts b/apps/server/src/api/v2/support/index.ts index bcbce625c..12fae5186 100644 --- a/apps/server/src/api/v2/support/index.ts +++ b/apps/server/src/api/v2/support/index.ts @@ -49,6 +49,8 @@ This is a POST endpoint that sends a support request to the Buster team. return c.json({ error: 'Help requests require a subject' }, { status: 400 }); } + const messageBlocks = createMessageBlocks(message); + const slackMessage = { text: 'New Support Request', blocks: [ @@ -96,13 +98,7 @@ This is a POST endpoint that sends a support request to the Buster team. }, ], }, - { - type: 'section', - text: { - type: 'mrkdwn', - text: `*Message:*\n${message}`, - }, - }, + ...messageBlocks, { type: 'section', text: { @@ -166,3 +162,46 @@ This is a POST endpoint that sends a support request to the Buster team. }); export default app; + +// Split long messages into multiple blocks if needed because of slack's 3000 character limit +const createMessageBlocks = (messageText: string) => { + const messagePrefix = '*Message:*\n'; + const maxTextLength = 2900; // Leave 100 charcter buffer + + if (messageText.length <= maxTextLength) { + return [ + { + type: 'section', + text: { + type: 'mrkdwn', + text: `${messagePrefix}${messageText}`, + }, + }, + ]; + } + + // Split into multiple blocks + const blocks = []; + const continuedMessagePrefix = '*Continued Message:*\n'; + let remainingText = messageText; + let isFirst = true; + + while (remainingText.length > 0) { + const chunkSize = maxTextLength; + const chunk = remainingText.substring(0, chunkSize); + const text = isFirst ? `${messagePrefix}${chunk}` : `${continuedMessagePrefix}${chunk}`; + + blocks.push({ + type: 'section', + text: { + type: 'mrkdwn', + text: text, + }, + }); + + remainingText = remainingText.substring(chunkSize); + isFirst = false; + } + + return blocks; +}; diff --git a/apps/web/src/components/features/modals/SupportModal.tsx b/apps/web/src/components/features/modals/SupportModal.tsx index 3420534d8..9899d5754 100644 --- a/apps/web/src/components/features/modals/SupportModal.tsx +++ b/apps/web/src/components/features/modals/SupportModal.tsx @@ -154,6 +154,7 @@ const FeedbackForm = React.memo(
setFeedback(e.target.value)} @@ -200,6 +201,7 @@ const HelpRequestForm = React.memo( setHelpRequest(e.target.value)} placeholder="A thorough and precise description of the the problem you are having..."