From 68e30c92bc29ab1b288a242951335803a42df27f Mon Sep 17 00:00:00 2001 From: Andrea Brancaleoni Date: Mon, 13 May 2024 17:53:29 +0200 Subject: [PATCH] sendSlackMessage: no more than 50 blocks --- src/sendSlackMessage.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/sendSlackMessage.js b/src/sendSlackMessage.js index ddcd348c..e068d94f 100644 --- a/src/sendSlackMessage.js +++ b/src/sendSlackMessage.js @@ -26,10 +26,21 @@ export default async function sendSlackMessage ({ const { markdownToBlocks } = await import('@tryfabric/mack') const web = new WebClient(token) - const blocks = await markdownToBlocks(message) + let blocks = await markdownToBlocks(message) if (debug) { console.log(blocks) } + if (blocks.length > 50) { + blocks = blocks.slice(0, 49) + blocks.push({ + type: 'section', + text: { + type: 'mrkdwn', + text: '...and more' + } + }) + } + const result = await web.chat.postMessage({ username, text: `${username} alert`,