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

feat: Slack bot notifications (#676)

This commit is contained in:
Matthieu Bollot 2024-04-08 00:33:29 +02:00 committed by GitHub
parent 22964cb375
commit 2f3dfe775e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 129 additions and 24 deletions

View file

@ -14,6 +14,30 @@ const valuesValidator = (value) => {
return true;
};
const buildAndSendSlackMessage = async (user, card, action) => {
const cardLink = `<${sails.config.custom.baseUrl}/cards/${card.id}|${card.name}>`;
let markdown;
switch (action.type) {
case Action.Types.CREATE_CARD:
markdown = `${cardLink} was created by ${user.name} in *${action.data.list.name}*`;
break;
case Action.Types.MOVE_CARD:
markdown = `${cardLink} was moved by ${user.name} to *${action.data.toList.name}*`;
break;
case Action.Types.COMMENT_CARD:
markdown = `*${user.name}* commented on ${cardLink}:\n>${action.data.text}`;
break;
default:
return;
}
await sails.helpers.utils.sendSlackMessage(markdown);
};
module.exports = {
inputs: {
values: {
@ -67,6 +91,10 @@ module.exports = {
),
);
if (sails.config.custom.slackBotToken) {
buildAndSendSlackMessage(values.user, values.card, action);
}
return action;
},
};