diff --git a/server/notification-providers/clickup.js b/server/notification-providers/clickup.js new file mode 100644 index 000000000..08e2360b1 --- /dev/null +++ b/server/notification-providers/clickup.js @@ -0,0 +1,47 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class ClickUp extends NotificationProvider { + name = "ClickUp"; + + /** + * @inheritdoc + */ + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + const okMsg = "Sent Successfully."; + + try { + let config = this.getAxiosConfigWithProxy({ + headers: { + Authorization: notification.clickupToken, + "Content-Type": "application/json", + }, + }); + + let content = msg; + if (heartbeatJSON) { + content += `\n\n**Time (${heartbeatJSON["timezone"]}):** ${heartbeatJSON["localDateTime"]}`; + } + + let address = this.extractAddress(monitorJSON); + if (address && !notification.clickupDisableUrl) { + content += `\n**Address:** ${address}`; + } + + const data = { + type: "message", + content, + content_format: "text/md", + }; + + const url = `https://api.clickup.com/api/v3/workspaces/${notification.clickupWorkspaceId}/chat/channels/${notification.clickupChannelId}/messages`; + + await axios.post(url, data, config); + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = ClickUp; diff --git a/server/notification.js b/server/notification.js index c678547e5..c98cf25e6 100644 --- a/server/notification.js +++ b/server/notification.js @@ -8,6 +8,7 @@ const Bale = require("./notification-providers/bale"); const Bark = require("./notification-providers/bark"); const BearSMS = require("./notification-providers/bearsms"); const Bitrix24 = require("./notification-providers/bitrix24"); +const ClickUp = require("./notification-providers/clickup"); const ClickSendSMS = require("./notification-providers/clicksendsms"); const CallMeBot = require("./notification-providers/call-me-bot"); const SMSC = require("./notification-providers/smsc"); @@ -127,6 +128,7 @@ class Notification { new Bark(), new BearSMS(), new Bitrix24(), + new ClickUp(), new ClickSendSMS(), new CallMeBot(), new SMSC(), diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 964798c89..67d5e2398 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -214,6 +214,7 @@ export default { let chatPlatforms = { bale: "Bale", Bitrix24: "Bitrix24", + ClickUp: "ClickUp", discord: "Discord", max: this.$t("maxMessenger"), fluxer: "Fluxer", diff --git a/src/components/notifications/ClickUp.vue b/src/components/notifications/ClickUp.vue new file mode 100644 index 000000000..14eac519f --- /dev/null +++ b/src/components/notifications/ClickUp.vue @@ -0,0 +1,77 @@ + + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 8a034af2c..c3674d20a 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -6,6 +6,7 @@ import Bale from "./Bale.vue"; import Bark from "./Bark.vue"; import BearSMS from "./BearSMS.vue"; import Bitrix24 from "./Bitrix24.vue"; +import ClickUp from "./ClickUp.vue"; import Notifery from "./Notifery.vue"; import ClickSendSMS from "./ClickSendSMS.vue"; import CallMeBot from "./CallMeBot.vue"; @@ -114,6 +115,7 @@ const NotificationFormList = { Bark: Bark, bearsms: BearSMS, Bitrix24: Bitrix24, + ClickUp: ClickUp, clicksendsms: ClickSendSMS, CallMeBot: CallMeBot, smsc: SMSC, diff --git a/src/lang/en.json b/src/lang/en.json index ad209af72..1347205d0 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -1152,6 +1152,12 @@ "Bitrix24 Webhook URL": "Bitrix24 Webhook URL", "wayToGetBitrix24Webhook": "You can create a webhook by following the steps at {0}", "bitrix24SupportUserID": "Enter your user ID in Bitrix24. You can find out the ID from the link by going to the user's profile.", + "ClickUp API Token": "ClickUp API Token", + "ClickUp API Token Description": "You can create a personal access token in ClickUp by going to Settings -> Integrations & ClickApps -> ClickUp API -> API Token", + "ClickUp Workspace ID": "ClickUp Workspace ID", + "ClickUp Workspace ID Description": "You can find it in your workspace's URL, right after app.clickup.com/, e.g. app.clickup.com/12345678/home.", + "ClickUp Channel ID": "ClickUp Channel ID", + "ClickUp Channel ID Description": "You can find it in the Chat channel's URL, right after /chat/r/, e.g. .../chat/r/abc123-4567.", "Saved.": "Saved.", "authUserInactiveOrDeleted": "The user is inactive or deleted.", "authInvalidToken": "Invalid Token.",