1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 05:09:43 +02:00

Added notifications about creating, moving, and commenting on the card

Co-authored-by: Elllone <elllone@diklosgroup.ru>
on-behalf-of: @DiklosGroup <contact@diklosgroup.ru>
This commit is contained in:
Elllone 2024-10-28 16:37:26 +03:00
parent 90a4cf27ef
commit 38316d7ff7
No known key found for this signature in database
GPG key ID: 65F0FF579B8D0D2D

View file

@ -38,6 +38,32 @@ const buildAndSendMessage = async (card, action, actorUser, send) => {
await send(markdown); await send(markdown);
}; };
const buildAndSendMessageForTelegramBot = async (card, action, actorUser, send) => {
const cardLink = `<a href="${sails.config.custom.baseUrl}/cards/${card.id}">${card.name}</a>`;
let html;
switch (action.type) {
case Action.Types.CREATE_CARD:
html = `${cardLink} was created by ${actorUser.name} in <b>${action.data.list.name}</b>`;
break;
case Action.Types.MOVE_CARD:
html = `${cardLink} was moved by ${actorUser.name} to <b>${action.data.toList.name}</b>`;
break;
case Action.Types.COMMENT_CARD: {
const commentedText =
action.data.text.length > 30 ? `${action.data.text.substring(0, 30)}...` : action.data.text;
html = `<b>${actorUser.name}</b> commented on ${cardLink}: <i>${commentedText}</i>`;
break;
}
default:
return;
}
await send(html);
};
module.exports = { module.exports = {
inputs: { inputs: {
values: { values: {
@ -119,6 +145,15 @@ module.exports = {
buildAndSendMessage(values.card, action, values.user, sails.helpers.utils.sendSlackMessage); 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) { if (sails.config.custom.googleChatWebhookUrl) {
buildAndSendMessage( buildAndSendMessage(
values.card, values.card,