From 38316d7ff745084c00c74ed269d458163bc6a946 Mon Sep 17 00:00:00 2001 From: Elllone Date: Mon, 28 Oct 2024 16:37:26 +0300 Subject: [PATCH] Added notifications about creating, moving, and commenting on the card Co-authored-by: Elllone on-behalf-of: @DiklosGroup --- server/api/helpers/actions/create-one.js | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/server/api/helpers/actions/create-one.js b/server/api/helpers/actions/create-one.js index eb9badf7..7e034448 100644 --- a/server/api/helpers/actions/create-one.js +++ b/server/api/helpers/actions/create-one.js @@ -38,6 +38,32 @@ const buildAndSendMessage = async (card, action, actorUser, send) => { await send(markdown); }; +const buildAndSendMessageForTelegramBot = async (card, action, actorUser, send) => { + const cardLink = `${card.name}`; + + let html; + switch (action.type) { + case Action.Types.CREATE_CARD: + html = `${cardLink} was created by ${actorUser.name} in ${action.data.list.name}`; + + break; + case Action.Types.MOVE_CARD: + html = `${cardLink} was moved by ${actorUser.name} to ${action.data.toList.name}`; + + break; + case Action.Types.COMMENT_CARD: { + const commentedText = + action.data.text.length > 30 ? `${action.data.text.substring(0, 30)}...` : action.data.text; + html = `${actorUser.name} commented on ${cardLink}: ${commentedText}`; + + break; + } + default: + return; + } + await send(html); +}; + module.exports = { inputs: { values: { @@ -119,6 +145,15 @@ module.exports = { buildAndSendMessage(values.card, action, values.user, sails.helpers.utils.sendSlackMessage); } + if (sails.config.custom.telegramChatId) { + buildAndSendMessageForTelegramBot( + values.card, + action, + values.user, + sails.helpers.utils.sendTelegramMessage, + ); + } + if (sails.config.custom.googleChatWebhookUrl) { buildAndSendMessage( values.card,