From 996f1c18f3ec5b459f88adcd533cbcc24932ea75 Mon Sep 17 00:00:00 2001 From: Ken Vu Date: Fri, 4 Nov 2022 15:44:04 +1300 Subject: [PATCH] Truncate the msg down to `2500` to avoid `invalid_blocks` error from Slack --- lib/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/index.ts b/lib/index.ts index dbbb167..268e914 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -91,10 +91,11 @@ const process = async ({ } if (typeof msg === 'string') { - payload.text = msg + const text = msg.length <= 2500? msg : `${msg.substring(0, 2500)}...`; + payload.text = text payload.blocks.push({ type: 'section', - text: { type: 'mrkdwn', text: `\`\`\`${msg}\`\`\`` } + text: { type: 'mrkdwn', text: `\`\`\`${text}\`\`\`` } }) }