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:
parent
90a4cf27ef
commit
38316d7ff7
1 changed files with 35 additions and 0 deletions
|
@ -38,6 +38,32 @@ const buildAndSendMessage = async (card, action, actorUser, send) => {
|
|||
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 = {
|
||||
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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue