mirror of
https://github.com/louislam/uptime-kuma.git
synced 2026-08-07 10:14:59 +00:00
feat: Add ClickUp notification provider (#7677)
This commit is contained in:
@@ -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;
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user