2024-09-04 15:28:09 +02:00
|
|
|
const buildAndSendMessage = async (card, actorUser, send) => {
|
|
|
|
await send(`*${card.name}* was deleted by ${actorUser.name}`);
|
2024-04-08 00:33:29 +02:00
|
|
|
};
|
|
|
|
|
2019-08-31 04:07:25 +05:00
|
|
|
module.exports = {
|
|
|
|
inputs: {
|
|
|
|
record: {
|
|
|
|
type: 'ref',
|
2019-11-05 18:01:42 +05:00
|
|
|
required: true,
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
2024-06-12 00:51:36 +02:00
|
|
|
project: {
|
|
|
|
type: 'ref',
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
board: {
|
|
|
|
type: 'ref',
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
type: 'ref',
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
actorUser: {
|
2024-04-08 00:33:29 +02:00
|
|
|
type: 'ref',
|
|
|
|
required: true,
|
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
request: {
|
2019-11-05 18:01:42 +05:00
|
|
|
type: 'ref',
|
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
|
2021-06-24 01:05:22 +05:00
|
|
|
async fn(inputs) {
|
2019-08-31 04:07:25 +05:00
|
|
|
const card = await Card.archiveOne(inputs.record.id);
|
|
|
|
|
|
|
|
if (card) {
|
|
|
|
sails.sockets.broadcast(
|
|
|
|
`board:${card.boardId}`,
|
|
|
|
'cardDelete',
|
|
|
|
{
|
2019-11-05 18:01:42 +05:00
|
|
|
item: card,
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
2019-11-05 18:01:42 +05:00
|
|
|
inputs.request,
|
2019-08-31 04:07:25 +05:00
|
|
|
);
|
2024-04-08 00:33:29 +02:00
|
|
|
|
2024-06-12 00:51:36 +02:00
|
|
|
sails.helpers.utils.sendWebhooks.with({
|
|
|
|
event: 'cardDelete',
|
|
|
|
data: {
|
|
|
|
item: card,
|
|
|
|
included: {
|
|
|
|
projects: [inputs.project],
|
|
|
|
boards: [inputs.board],
|
|
|
|
lists: [inputs.list],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
user: inputs.actorUser,
|
|
|
|
});
|
|
|
|
|
2024-04-08 00:33:29 +02:00
|
|
|
if (sails.config.custom.slackBotToken) {
|
2024-09-04 15:28:09 +02:00
|
|
|
buildAndSendMessage(card, inputs.actorUser, sails.helpers.utils.sendSlackMessage);
|
2024-04-14 16:39:57 +02:00
|
|
|
}
|
2024-09-04 15:28:09 +02:00
|
|
|
|
2024-04-14 16:39:57 +02:00
|
|
|
if (sails.config.custom.googleChatWebhookUrl) {
|
2024-09-04 15:28:09 +02:00
|
|
|
buildAndSendMessage(card, inputs.actorUser, sails.helpers.utils.sendGoogleChatMessage);
|
2024-04-08 00:33:29 +02:00
|
|
|
}
|
2019-08-31 04:07:25 +05:00
|
|
|
}
|
|
|
|
|
2021-06-24 01:05:22 +05:00
|
|
|
return card;
|
2019-11-05 18:01:42 +05:00
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
};
|