1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-22 06:39:44 +02:00

added new custom service with slack integration helper functions; added axios package; added notifications for card create, delete, and update (move); added notifications for comment create

This commit is contained in:
Brad Bahls 2023-12-23 08:52:07 -07:00
parent da63598de3
commit 1043dacd67
No known key found for this signature in database
GPG key ID: 236D25760FA8AF9B
6 changed files with 110 additions and 0 deletions

View file

@ -1,4 +1,5 @@
const moment = require('moment');
const services = require('../../services/custom');
const Errors = {
NOT_ENOUGH_RIGHTS: {
@ -175,6 +176,8 @@ module.exports = {
'isSubscribed',
]);
const cardPositionBefore = card.position;
card = await sails.helpers.cards.updateOne
.with({
board,
@ -195,6 +198,17 @@ module.exports = {
throw Errors.CARD_NOT_FOUND;
}
const cardPositionAfter = card.position;
const cardMoved = cardPositionBefore !== cardPositionAfter;
if (cardMoved) {
const cardUrl = services.buildCardUrl(card);
const messageText = cardUrl + ' was moved by ' + currentUser.username + ' to *' + nextList.name + '*';
services.sendSlackMessage(messageText)
.then(() => { console.log('Slack message sent successfully.'); })
.catch((error) => { console.error('Failed to send Slack message:', error.message); });
}
return {
item: card,
};