mirror of
https://github.com/plankanban/planka.git
synced 2025-08-01 19:45:26 +02:00
feat: add Google Chat Webhook implementation
This commit is contained in:
parent
c7d201baaf
commit
d92e53ef21
3 changed files with 19 additions and 6 deletions
|
@ -14,7 +14,7 @@ const valuesValidator = (value) => {
|
|||
return true;
|
||||
};
|
||||
|
||||
const buildAndSendSlackMessage = async (user, card, action) => {
|
||||
const buildAndSendMessage = async (user, card, action, send) => {
|
||||
const cardLink = `<${sails.config.custom.baseUrl}/cards/${card.id}|${card.name}>`;
|
||||
|
||||
let markdown;
|
||||
|
@ -35,7 +35,7 @@ const buildAndSendSlackMessage = async (user, card, action) => {
|
|||
return;
|
||||
}
|
||||
|
||||
await sails.helpers.utils.sendSlackMessage(markdown);
|
||||
await send(markdown);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
@ -92,7 +92,16 @@ module.exports = {
|
|||
);
|
||||
|
||||
if (sails.config.custom.slackBotToken) {
|
||||
buildAndSendSlackMessage(values.user, values.card, action);
|
||||
buildAndSendMessage(values.user, values.card, action, sails.helpers.utils.sendSlackMessage);
|
||||
}
|
||||
|
||||
if (sails.config.custom.googleChatWebhookUrl) {
|
||||
buildAndSendMessage(
|
||||
values.user,
|
||||
values.card,
|
||||
action,
|
||||
sails.helpers.utils.sendGoogleChatMessage,
|
||||
);
|
||||
}
|
||||
|
||||
return action;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const buildAndSendSlackMessage = async (user, card) => {
|
||||
await sails.helpers.utils.sendSlackMessage(`*${card.name}* was deleted by ${user.name}`);
|
||||
const buildAndSendMessage = async (user, card, send) => {
|
||||
await send(`*${card.name}* was deleted by ${user.name}`);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
@ -31,7 +31,10 @@ module.exports = {
|
|||
);
|
||||
|
||||
if (sails.config.custom.slackBotToken) {
|
||||
buildAndSendSlackMessage(inputs.user, card);
|
||||
buildAndSendMessage(inputs.user, card, sails.helpers.utils.sendSlackMessage);
|
||||
}
|
||||
if (sails.config.custom.googleChatWebhookUrl) {
|
||||
buildAndSendMessage(inputs.user, card, sails.helpers.utils.sendSlackMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,4 +61,5 @@ module.exports.custom = {
|
|||
|
||||
slackBotToken: process.env.SLACK_BOT_TOKEN,
|
||||
slackChannelId: process.env.SLACK_CHANNEL_ID,
|
||||
googleChatWebhookUrl: process.env.GOOGLE_CHAT_WEBHOOK_URL,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue