mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-10-04 14:39:19 +08:00
feature: Add an option to enable Telegram to work behind a proxy. (#6125)
Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
@@ -17,12 +17,14 @@ class Elks extends NotificationProvider {
|
||||
data.append("to", notification.elksToNumber );
|
||||
data.append("message", msg);
|
||||
|
||||
const config = {
|
||||
let config = {
|
||||
headers: {
|
||||
"Authorization": "Basic " + Buffer.from(`${notification.elksUsername}:${notification.elksAuthToken}`).toString("base64")
|
||||
}
|
||||
};
|
||||
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
await axios.post(url, data, config);
|
||||
|
||||
return okMsg;
|
||||
|
@@ -30,6 +30,8 @@ class Alerta extends NotificationProvider {
|
||||
type: "exceptionAlert",
|
||||
};
|
||||
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
if (heartbeatJSON == null) {
|
||||
let postData = Object.assign({
|
||||
event: "msg",
|
||||
|
@@ -41,7 +41,9 @@ class AlertNow extends NotificationProvider {
|
||||
"event_id": eventId,
|
||||
};
|
||||
|
||||
await axios.post(notification.alertNowWebhookURL, data);
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
|
||||
await axios.post(notification.alertNowWebhookURL, data, config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
|
@@ -72,6 +72,8 @@ class AliyunSMS extends NotificationProvider {
|
||||
data: qs.stringify(params),
|
||||
};
|
||||
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
let result = await axios(config);
|
||||
if (result.data.Message === "OK") {
|
||||
return true;
|
||||
|
@@ -96,12 +96,13 @@ class Bark extends NotificationProvider {
|
||||
*/
|
||||
async postNotification(notification, title, subtitle, endpoint) {
|
||||
let result;
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
if (notification.apiVersion === "v1" || notification.apiVersion == null) {
|
||||
// url encode title and subtitle
|
||||
title = encodeURIComponent(title);
|
||||
subtitle = encodeURIComponent(subtitle);
|
||||
const params = this.additionalParameters(notification);
|
||||
result = await axios.get(`${endpoint}/${title}/${subtitle}${params}`);
|
||||
result = await axios.get(`${endpoint}/${title}/${subtitle}${params}`, config);
|
||||
} else {
|
||||
result = await axios.post(`${endpoint}/push`, {
|
||||
title,
|
||||
@@ -109,7 +110,7 @@ class Bark extends NotificationProvider {
|
||||
icon: barkNotificationAvatar,
|
||||
sound: notification.barkSound || "telegraph", // default sound is telegraph
|
||||
group: notification.barkGroup || "UptimeKuma", // default group is UptimeKuma
|
||||
});
|
||||
}, config);
|
||||
}
|
||||
this.checkResult(result);
|
||||
if (result.statusText != null) {
|
||||
|
@@ -19,7 +19,8 @@ class Bitrix24 extends NotificationProvider {
|
||||
"ATTACH[BLOCKS][0][MESSAGE]": msg
|
||||
};
|
||||
|
||||
await axios.get(`${notification.bitrix24WebhookURL}/im.notify.system.add.json`, { params });
|
||||
let config = this.getAxiosConfigWithProxy({ params });
|
||||
await axios.get(`${notification.bitrix24WebhookURL}/im.notify.system.add.json`, config);
|
||||
return okMsg;
|
||||
|
||||
} catch (error) {
|
||||
|
@@ -18,6 +18,7 @@ class Brevo extends NotificationProvider {
|
||||
"api-key": notification.brevoApiKey,
|
||||
},
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
let to = [{ email: notification.brevoToEmail }];
|
||||
|
||||
|
@@ -12,7 +12,8 @@ class CallMeBot extends NotificationProvider {
|
||||
try {
|
||||
const url = new URL(notification.callMeBotEndpoint);
|
||||
url.searchParams.set("text", msg);
|
||||
await axios.get(url.toString());
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
await axios.get(url.toString(), config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
|
@@ -22,7 +22,8 @@ class Cellsynt extends NotificationProvider {
|
||||
}
|
||||
};
|
||||
try {
|
||||
const resp = await axios.post("https://se-1.cellsynt.net/sms.php", null, data);
|
||||
let config = this.getAxiosConfigWithProxy(data);
|
||||
const resp = await axios.post("https://se-1.cellsynt.net/sms.php", null, config);
|
||||
if (resp.data == null ) {
|
||||
throw new Error("Could not connect to Cellsynt, please try again.");
|
||||
} else if (resp.data.includes("Error:")) {
|
||||
|
@@ -29,6 +29,7 @@ class ClickSendSMS extends NotificationProvider {
|
||||
}
|
||||
]
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
let resp = await axios.post(url, data, config);
|
||||
if (resp.data.data.messages[0].status !== "SUCCESS") {
|
||||
let error = "Something gone wrong. Api returned " + resp.data.data.messages[0].status + ".";
|
||||
|
@@ -60,6 +60,7 @@ class DingDing extends NotificationProvider {
|
||||
url: `${notification.webHookUrl}×tamp=${timestamp}&sign=${encodeURIComponent(this.sign(timestamp, notification.secretKey))}`,
|
||||
data: JSON.stringify(params),
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
let result = await axios(config);
|
||||
if (result.data.errmsg === "ok") {
|
||||
|
@@ -12,6 +12,7 @@ class Discord extends NotificationProvider {
|
||||
const okMsg = "Sent Successfully.";
|
||||
|
||||
try {
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
const discordDisplayName = notification.discordUsername || "Uptime Kuma";
|
||||
const webhookUrl = new URL(notification.discordWebhookUrl);
|
||||
if (notification.discordChannelType === "postToThread") {
|
||||
@@ -21,7 +22,7 @@ class Discord extends NotificationProvider {
|
||||
// Check if the webhook has an avatar
|
||||
let webhookHasAvatar = true;
|
||||
try {
|
||||
const webhookInfo = await axios.get(webhookUrl.toString());
|
||||
const webhookInfo = await axios.get(webhookUrl.toString(), config);
|
||||
webhookHasAvatar = !!webhookInfo.data.avatar;
|
||||
} catch (e) {
|
||||
// If we can't verify, we assume he has an avatar to avoid forcing the default avatar
|
||||
@@ -40,7 +41,7 @@ class Discord extends NotificationProvider {
|
||||
if (notification.discordChannelType === "createNewForumPost") {
|
||||
discordtestdata.thread_name = notification.postName;
|
||||
}
|
||||
await axios.post(webhookUrl.toString(), discordtestdata);
|
||||
await axios.post(webhookUrl.toString(), discordtestdata, config);
|
||||
return okMsg;
|
||||
}
|
||||
|
||||
@@ -82,7 +83,7 @@ class Discord extends NotificationProvider {
|
||||
discorddowndata.content = notification.discordPrefixMessage;
|
||||
}
|
||||
|
||||
await axios.post(webhookUrl.toString(), discorddowndata);
|
||||
await axios.post(webhookUrl.toString(), discorddowndata, config);
|
||||
return okMsg;
|
||||
|
||||
} else if (heartbeatJSON["status"] === UP) {
|
||||
@@ -124,7 +125,7 @@ class Discord extends NotificationProvider {
|
||||
discordupdata.content = notification.discordPrefixMessage;
|
||||
}
|
||||
|
||||
await axios.post(webhookUrl.toString(), discordupdata);
|
||||
await axios.post(webhookUrl.toString(), discordupdata, config);
|
||||
return okMsg;
|
||||
}
|
||||
} catch (error) {
|
||||
|
@@ -11,13 +11,14 @@ class Evolution extends NotificationProvider {
|
||||
const okMsg = "Sent Successfully.";
|
||||
|
||||
try {
|
||||
const config = {
|
||||
let config = {
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
"apikey": notification.evolutionAuthToken,
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
let data = {
|
||||
"number": notification.evolutionRecipient,
|
||||
|
@@ -12,6 +12,7 @@ class Feishu extends NotificationProvider {
|
||||
const okMsg = "Sent Successfully.";
|
||||
|
||||
try {
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
if (heartbeatJSON == null) {
|
||||
let testdata = {
|
||||
msg_type: "text",
|
||||
@@ -19,7 +20,7 @@ class Feishu extends NotificationProvider {
|
||||
text: msg,
|
||||
},
|
||||
};
|
||||
await axios.post(notification.feishuWebHookUrl, testdata);
|
||||
await axios.post(notification.feishuWebHookUrl, testdata, config);
|
||||
return okMsg;
|
||||
}
|
||||
|
||||
@@ -49,7 +50,7 @@ class Feishu extends NotificationProvider {
|
||||
]
|
||||
}
|
||||
};
|
||||
await axios.post(notification.feishuWebHookUrl, downdata);
|
||||
await axios.post(notification.feishuWebHookUrl, downdata, config);
|
||||
return okMsg;
|
||||
}
|
||||
|
||||
@@ -79,7 +80,7 @@ class Feishu extends NotificationProvider {
|
||||
]
|
||||
}
|
||||
};
|
||||
await axios.post(notification.feishuWebHookUrl, updata);
|
||||
await axios.post(notification.feishuWebHookUrl, updata, config);
|
||||
return okMsg;
|
||||
}
|
||||
} catch (error) {
|
||||
|
@@ -11,10 +11,11 @@ class FreeMobile extends NotificationProvider {
|
||||
const okMsg = "Sent Successfully.";
|
||||
|
||||
try {
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
await axios.post(`https://smsapi.free-mobile.fr/sendmsg?msg=${encodeURIComponent(msg.replace("🔴", "⛔️"))}`, {
|
||||
"user": notification.freemobileUser,
|
||||
"pass": notification.freemobilePass,
|
||||
});
|
||||
}, config);
|
||||
|
||||
return okMsg;
|
||||
|
||||
|
@@ -24,6 +24,7 @@ class GoAlert extends NotificationProvider {
|
||||
let config = {
|
||||
headers: headers
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
await axios.post(`${notification.goAlertBaseURL}/api/v2/generic/incoming?token=${notification.goAlertToken}`, data, config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
|
@@ -13,6 +13,7 @@ class GoogleChat extends NotificationProvider {
|
||||
const okMsg = "Sent Successfully.";
|
||||
|
||||
try {
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
// Google Chat message formatting: https://developers.google.com/chat/api/guides/message-formats/basic
|
||||
if (notification.googleChatUseTemplate && notification.googleChatTemplate) {
|
||||
// Send message using template
|
||||
@@ -23,7 +24,7 @@ class GoogleChat extends NotificationProvider {
|
||||
heartbeatJSON
|
||||
);
|
||||
const data = { "text": renderedText };
|
||||
await axios.post(notification.googleChatWebhookURL, data);
|
||||
await axios.post(notification.googleChatWebhookURL, data, config);
|
||||
return okMsg;
|
||||
}
|
||||
|
||||
@@ -95,7 +96,7 @@ class GoogleChat extends NotificationProvider {
|
||||
],
|
||||
};
|
||||
|
||||
await axios.post(notification.googleChatWebhookURL, data);
|
||||
await axios.post(notification.googleChatWebhookURL, data, config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
|
@@ -31,8 +31,7 @@ class Gorush extends NotificationProvider {
|
||||
}
|
||||
]
|
||||
};
|
||||
let config = {};
|
||||
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
await axios.post(`${notification.gorushServerURL}/api/push`, data, config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
|
@@ -11,6 +11,7 @@ class Gotify extends NotificationProvider {
|
||||
const okMsg = "Sent Successfully.";
|
||||
|
||||
try {
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
if (notification.gotifyserverurl && notification.gotifyserverurl.endsWith("/")) {
|
||||
notification.gotifyserverurl = notification.gotifyserverurl.slice(0, -1);
|
||||
}
|
||||
@@ -18,7 +19,7 @@ class Gotify extends NotificationProvider {
|
||||
"message": msg,
|
||||
"priority": notification.gotifyPriority || 8,
|
||||
"title": "Uptime-Kuma",
|
||||
});
|
||||
}, config);
|
||||
|
||||
return okMsg;
|
||||
|
||||
|
@@ -16,13 +16,14 @@ class GrafanaOncall extends NotificationProvider {
|
||||
}
|
||||
|
||||
try {
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
if (heartbeatJSON === null) {
|
||||
let grafanaupdata = {
|
||||
title: "General notification",
|
||||
message: msg,
|
||||
state: "alerting",
|
||||
};
|
||||
await axios.post(notification.GrafanaOncallURL, grafanaupdata);
|
||||
await axios.post(notification.GrafanaOncallURL, grafanaupdata, config);
|
||||
return okMsg;
|
||||
} else if (heartbeatJSON["status"] === DOWN) {
|
||||
let grafanadowndata = {
|
||||
@@ -30,7 +31,7 @@ class GrafanaOncall extends NotificationProvider {
|
||||
message: heartbeatJSON["msg"],
|
||||
state: "alerting",
|
||||
};
|
||||
await axios.post(notification.GrafanaOncallURL, grafanadowndata);
|
||||
await axios.post(notification.GrafanaOncallURL, grafanadowndata, config);
|
||||
return okMsg;
|
||||
} else if (heartbeatJSON["status"] === UP) {
|
||||
let grafanaupdata = {
|
||||
@@ -38,7 +39,7 @@ class GrafanaOncall extends NotificationProvider {
|
||||
message: heartbeatJSON["msg"],
|
||||
state: "ok",
|
||||
};
|
||||
await axios.post(notification.GrafanaOncallURL, grafanaupdata);
|
||||
await axios.post(notification.GrafanaOncallURL, grafanaupdata, config);
|
||||
return okMsg;
|
||||
}
|
||||
} catch (error) {
|
||||
|
@@ -14,6 +14,7 @@ class GtxMessaging extends NotificationProvider {
|
||||
const text = msg.replaceAll("🔴 ", "").replaceAll("✅ ", "");
|
||||
|
||||
try {
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
const data = new URLSearchParams();
|
||||
data.append("from", notification.gtxMessagingFrom.trim());
|
||||
data.append("to", notification.gtxMessagingTo.trim());
|
||||
@@ -21,7 +22,7 @@ class GtxMessaging extends NotificationProvider {
|
||||
|
||||
const url = `https://rest.gtx-messaging.net/smsc/sendsms/${notification.gtxMessagingApiKey}/json`;
|
||||
|
||||
await axios.post(url, data);
|
||||
await axios.post(url, data, config);
|
||||
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
|
@@ -18,7 +18,7 @@ class HeiiOnCall extends NotificationProvider {
|
||||
payload["url"] = baseURL + getMonitorRelativeURL(monitorJSON.id);
|
||||
}
|
||||
|
||||
const config = {
|
||||
let config = {
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
@@ -28,6 +28,7 @@ class HeiiOnCall extends NotificationProvider {
|
||||
const heiiUrl = `https://heiioncall.com/triggers/${notification.heiiOnCallTriggerId}/`;
|
||||
// docs https://heiioncall.com/docs#manual-triggers
|
||||
try {
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
if (!heartbeatJSON) {
|
||||
// Testing or general notification like certificate expiry
|
||||
payload["msg"] = msg;
|
||||
|
@@ -15,6 +15,13 @@ class HomeAssistant extends NotificationProvider {
|
||||
const notificationService = notification?.notificationService || defaultNotificationService;
|
||||
|
||||
try {
|
||||
let config = {
|
||||
headers: {
|
||||
Authorization: `Bearer ${notification.longLivedAccessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
await axios.post(
|
||||
`${notification.homeAssistantUrl.trim().replace(/\/*$/, "")}/api/services/notify/${notificationService}`,
|
||||
{
|
||||
@@ -26,14 +33,7 @@ class HomeAssistant extends NotificationProvider {
|
||||
channel: "Uptime Kuma",
|
||||
icon_url: "https://github.com/louislam/uptime-kuma/blob/master/public/icon.png?raw=true",
|
||||
} }),
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${notification.longLivedAccessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
}, config);
|
||||
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
|
@@ -31,6 +31,8 @@ class Keep extends NotificationProvider {
|
||||
|
||||
let webhookURL = url + "/alerts/event/uptimekuma";
|
||||
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
await axios.post(webhookURL, data, config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
|
@@ -22,6 +22,7 @@ class Kook extends NotificationProvider {
|
||||
},
|
||||
};
|
||||
try {
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
await axios.post(url, data, config);
|
||||
return okMsg;
|
||||
|
||||
|
@@ -19,6 +19,7 @@ class Line extends NotificationProvider {
|
||||
"Authorization": "Bearer " + notification.lineChannelAccessToken
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
if (heartbeatJSON == null) {
|
||||
let testMessage = {
|
||||
"to": notification.lineUserID,
|
||||
|
@@ -20,6 +20,7 @@ class LineNotify extends NotificationProvider {
|
||||
"Authorization": "Bearer " + notification.lineNotifyAccessToken
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
if (heartbeatJSON == null) {
|
||||
let testMessage = {
|
||||
"message": msg,
|
||||
|
@@ -13,13 +13,14 @@ class LunaSea extends NotificationProvider {
|
||||
const url = "https://notify.lunasea.app/v1";
|
||||
|
||||
try {
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
const target = this.getTarget(notification);
|
||||
if (heartbeatJSON == null) {
|
||||
let testdata = {
|
||||
"title": "Uptime Kuma Alert",
|
||||
"body": msg,
|
||||
};
|
||||
await axios.post(`${url}/custom/${target}`, testdata);
|
||||
await axios.post(`${url}/custom/${target}`, testdata, config);
|
||||
return okMsg;
|
||||
}
|
||||
|
||||
@@ -30,7 +31,7 @@ class LunaSea extends NotificationProvider {
|
||||
heartbeatJSON["msg"] +
|
||||
`\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`
|
||||
};
|
||||
await axios.post(`${url}/custom/${target}`, downdata);
|
||||
await axios.post(`${url}/custom/${target}`, downdata, config);
|
||||
return okMsg;
|
||||
}
|
||||
|
||||
@@ -41,7 +42,7 @@ class LunaSea extends NotificationProvider {
|
||||
heartbeatJSON["msg"] +
|
||||
`\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`
|
||||
};
|
||||
await axios.post(`${url}/custom/${target}`, updata);
|
||||
await axios.post(`${url}/custom/${target}`, updata, config);
|
||||
return okMsg;
|
||||
}
|
||||
|
||||
|
@@ -37,6 +37,7 @@ class Matrix extends NotificationProvider {
|
||||
"body": msg
|
||||
};
|
||||
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
await axios.put(`${notification.homeserverUrl}/_matrix/client/r0/rooms/${roomId}/send/m.room.message/${randomString}`, data, config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
|
@@ -12,6 +12,7 @@ class Mattermost extends NotificationProvider {
|
||||
const okMsg = "Sent Successfully.";
|
||||
|
||||
try {
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
const mattermostUserName = notification.mattermostusername || "Uptime Kuma";
|
||||
// If heartbeatJSON is null, assume non monitoring notification (Certificate warning) or testing.
|
||||
if (heartbeatJSON == null) {
|
||||
@@ -19,7 +20,7 @@ class Mattermost extends NotificationProvider {
|
||||
username: mattermostUserName,
|
||||
text: msg,
|
||||
};
|
||||
await axios.post(notification.mattermostWebhookUrl, mattermostTestData);
|
||||
await axios.post(notification.mattermostWebhookUrl, mattermostTestData, config);
|
||||
return okMsg;
|
||||
}
|
||||
|
||||
@@ -98,7 +99,7 @@ class Mattermost extends NotificationProvider {
|
||||
},
|
||||
],
|
||||
};
|
||||
await axios.post(notification.mattermostWebhookUrl, mattermostdata);
|
||||
await axios.post(notification.mattermostWebhookUrl, mattermostdata, config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
|
@@ -42,7 +42,8 @@ class Notifery extends NotificationProvider {
|
||||
"x-api-key": notification.notiferyApiKey,
|
||||
};
|
||||
|
||||
await axios.post(url, data, { headers });
|
||||
let config = this.getAxiosConfigWithProxy({ headers });
|
||||
await axios.post(url, data, config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
|
@@ -1,5 +1,6 @@
|
||||
const { Liquid } = require("liquidjs");
|
||||
const { DOWN } = require("../../src/util");
|
||||
const ProxyAgent = require("proxy-agent");
|
||||
|
||||
class NotificationProvider {
|
||||
|
||||
@@ -115,6 +116,22 @@ class NotificationProvider {
|
||||
|
||||
throw new Error(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns axios config with proxy agent if proxy env is set.
|
||||
* @param {object} axiosConfig - Axios config containing params
|
||||
* @returns {object} Axios config
|
||||
*/
|
||||
getAxiosConfigWithProxy(axiosConfig = {}) {
|
||||
const proxyEnv = process.env.notification_proxy || process.env.NOTIFICATION_PROXY;
|
||||
if (proxyEnv) {
|
||||
const agent = new ProxyAgent(proxyEnv);
|
||||
axiosConfig.httpsAgent = agent;
|
||||
axiosConfig.httpAgent = agent;
|
||||
axiosConfig.proxy = false;
|
||||
}
|
||||
return axiosConfig;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NotificationProvider;
|
||||
|
@@ -22,6 +22,8 @@ class Ntfy extends NotificationProvider {
|
||||
"Authorization": "Bearer " + notification.ntfyaccesstoken,
|
||||
};
|
||||
}
|
||||
let config = { headers };
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
// If heartbeatJSON is null, assume non monitoring notification (Certificate warning) or testing.
|
||||
if (heartbeatJSON == null) {
|
||||
let ntfyTestData = {
|
||||
@@ -31,7 +33,7 @@ class Ntfy extends NotificationProvider {
|
||||
"priority": notification.ntfyPriority,
|
||||
"tags": [ "test_tube" ],
|
||||
};
|
||||
await axios.post(notification.ntfyserverurl, ntfyTestData, { headers: headers });
|
||||
await axios.post(notification.ntfyserverurl, ntfyTestData, config);
|
||||
return okMsg;
|
||||
}
|
||||
let tags = [];
|
||||
@@ -70,7 +72,7 @@ class Ntfy extends NotificationProvider {
|
||||
data.icon = notification.ntfyIcon;
|
||||
}
|
||||
|
||||
await axios.post(notification.ntfyserverurl, data, { headers: headers });
|
||||
await axios.post(notification.ntfyserverurl, data, config);
|
||||
|
||||
return okMsg;
|
||||
|
||||
|
@@ -22,6 +22,7 @@ class Octopush extends NotificationProvider {
|
||||
"cache-control": "no-cache"
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
let data = {
|
||||
"recipients": [
|
||||
{
|
||||
@@ -53,6 +54,7 @@ class Octopush extends NotificationProvider {
|
||||
},
|
||||
params: data
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
// V1 API returns 200 even on error so we must check
|
||||
// response data
|
||||
|
@@ -25,6 +25,7 @@ class OneBot extends NotificationProvider {
|
||||
"Authorization": "Bearer " + notification.accessToken,
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
let pushText = "UptimeKuma Alert: " + msg;
|
||||
let data = {
|
||||
"auto_escape": true,
|
||||
|
@@ -13,12 +13,13 @@ class OneChat extends NotificationProvider {
|
||||
const url = "https://chat-api.one.th/message/api/v1/push_message";
|
||||
|
||||
try {
|
||||
const config = {
|
||||
let config = {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: "Bearer " + notification.accessToken,
|
||||
},
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
if (heartbeatJSON == null) {
|
||||
const testMessage = {
|
||||
to: notification.recieverId,
|
||||
|
@@ -33,6 +33,7 @@ class Onesender extends NotificationProvider {
|
||||
"Authorization": "Bearer " + notification.onesenderToken,
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
await axios.post(notification.onesenderURL, data, config);
|
||||
return okMsg;
|
||||
|
||||
|
@@ -80,6 +80,7 @@ class Opsgenie extends NotificationProvider {
|
||||
"Authorization": `GenieKey ${notification.opsgenieApiKey}`,
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
let res = await axios.post(url, data, config);
|
||||
if (res.status == null) {
|
||||
|
@@ -27,6 +27,7 @@ class PromoSMS extends NotificationProvider {
|
||||
"Accept": "text/json",
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
let data = {
|
||||
"recipients": [ notification.promosmsPhoneNumber ],
|
||||
//Trim message to maximum length of 1 SMS or 4 if we allowed long messages
|
||||
|
@@ -12,6 +12,7 @@ class Pumble extends NotificationProvider {
|
||||
const okMsg = "Sent Successfully.";
|
||||
|
||||
try {
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
if (heartbeatJSON === null && monitorJSON === null) {
|
||||
let data = {
|
||||
"attachments": [
|
||||
@@ -23,7 +24,7 @@ class Pumble extends NotificationProvider {
|
||||
]
|
||||
};
|
||||
|
||||
await axios.post(notification.webhookURL, data);
|
||||
await axios.post(notification.webhookURL, data, config);
|
||||
return okMsg;
|
||||
}
|
||||
|
||||
@@ -37,7 +38,7 @@ class Pumble extends NotificationProvider {
|
||||
]
|
||||
};
|
||||
|
||||
await axios.post(notification.webhookURL, data);
|
||||
await axios.post(notification.webhookURL, data, config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
|
@@ -20,6 +20,7 @@ class Pushbullet extends NotificationProvider {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
if (heartbeatJSON == null) {
|
||||
let data = {
|
||||
"type": "note",
|
||||
|
@@ -33,7 +33,8 @@ class PushDeer extends NotificationProvider {
|
||||
};
|
||||
|
||||
try {
|
||||
let res = await axios.post(url, data);
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
let res = await axios.post(url, data, config);
|
||||
|
||||
if ("error" in res.data) {
|
||||
let error = res.data.error;
|
||||
|
@@ -41,8 +41,9 @@ class Pushover extends NotificationProvider {
|
||||
}
|
||||
|
||||
try {
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
if (heartbeatJSON == null) {
|
||||
await axios.post(url, data);
|
||||
await axios.post(url, data, config);
|
||||
return okMsg;
|
||||
}
|
||||
|
||||
@@ -52,7 +53,7 @@ class Pushover extends NotificationProvider {
|
||||
}
|
||||
|
||||
data.message += `\n<b>Time (${heartbeatJSON["timezone"]})</b>: ${heartbeatJSON["localDateTime"]}`;
|
||||
await axios.post(url, data);
|
||||
await axios.post(url, data, config);
|
||||
return okMsg;
|
||||
|
||||
} catch (error) {
|
||||
|
@@ -17,11 +17,12 @@ class PushPlus extends NotificationProvider {
|
||||
const okMsg = "Sent Successfully.";
|
||||
const url = "https://www.pushplus.plus/send";
|
||||
try {
|
||||
const config = {
|
||||
let config = {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
const params = {
|
||||
"token": notification.pushPlusSendKey,
|
||||
"title": this.checkStatus(heartbeatJSON, monitorJSON),
|
||||
|
@@ -11,6 +11,7 @@ class Pushy extends NotificationProvider {
|
||||
const okMsg = "Sent Successfully.";
|
||||
|
||||
try {
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
await axios.post(`https://api.pushy.me/push?api_key=${notification.pushyAPIKey}`, {
|
||||
"to": notification.pushyToken,
|
||||
"data": {
|
||||
@@ -21,7 +22,7 @@ class Pushy extends NotificationProvider {
|
||||
"badge": 1,
|
||||
"sound": "ping.aiff"
|
||||
}
|
||||
});
|
||||
}, config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
|
@@ -14,6 +14,7 @@ class RocketChat extends NotificationProvider {
|
||||
const okMsg = "Sent Successfully.";
|
||||
|
||||
try {
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
if (heartbeatJSON == null) {
|
||||
let data = {
|
||||
"text": msg,
|
||||
@@ -21,7 +22,7 @@ class RocketChat extends NotificationProvider {
|
||||
"username": notification.rocketusername,
|
||||
"icon_emoji": notification.rocketiconemo,
|
||||
};
|
||||
await axios.post(notification.rocketwebhookURL, data);
|
||||
await axios.post(notification.rocketwebhookURL, data, config);
|
||||
return okMsg;
|
||||
}
|
||||
|
||||
@@ -55,7 +56,7 @@ class RocketChat extends NotificationProvider {
|
||||
data.attachments[0].title_link = baseURL + getMonitorRelativeURL(monitorJSON.id);
|
||||
}
|
||||
|
||||
await axios.post(notification.rocketwebhookURL, data);
|
||||
await axios.post(notification.rocketwebhookURL, data, config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
|
@@ -17,7 +17,7 @@ class SendGrid extends NotificationProvider {
|
||||
Authorization: `Bearer ${notification.sendgridApiKey}`,
|
||||
},
|
||||
};
|
||||
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
let personalizations = {
|
||||
to: [{ email: notification.sendgridToEmail }],
|
||||
};
|
||||
|
@@ -18,10 +18,11 @@ class ServerChan extends NotificationProvider {
|
||||
: `https://sctapi.ftqq.com/${notification.serverChanSendKey}.send`;
|
||||
|
||||
try {
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
await axios.post(url, {
|
||||
"title": this.checkStatus(heartbeatJSON, monitorJSON),
|
||||
"desp": msg,
|
||||
});
|
||||
}, config);
|
||||
|
||||
return okMsg;
|
||||
|
||||
|
@@ -17,6 +17,7 @@ class SerwerSMS extends NotificationProvider {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
let data = {
|
||||
"username": notification.serwersmsUsername,
|
||||
"password": notification.serwersmsPassword,
|
||||
|
@@ -17,7 +17,7 @@ class SevenIO extends NotificationProvider {
|
||||
text: msg,
|
||||
};
|
||||
|
||||
const config = {
|
||||
let config = {
|
||||
baseURL: "https://gateway.seven.io/api/",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -26,6 +26,7 @@ class SevenIO extends NotificationProvider {
|
||||
};
|
||||
|
||||
try {
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
// testing or certificate expiry notification
|
||||
if (heartbeatJSON == null) {
|
||||
await axios.post("sms", data, config);
|
||||
|
@@ -17,7 +17,7 @@ class Signal extends NotificationProvider {
|
||||
"recipients": notification.signalRecipients.replace(/\s/g, "").split(","),
|
||||
};
|
||||
let config = {};
|
||||
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
await axios.post(notification.signalURL, data, config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
|
@@ -21,11 +21,12 @@ class SIGNL4 extends NotificationProvider {
|
||||
monitorUrl: this.extractAddress(monitorJSON),
|
||||
};
|
||||
|
||||
const config = {
|
||||
let config = {
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
if (heartbeatJSON == null) {
|
||||
// Test alert
|
||||
|
@@ -131,6 +131,7 @@ class Slack extends NotificationProvider {
|
||||
}
|
||||
|
||||
try {
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
if (heartbeatJSON == null) {
|
||||
let data = {
|
||||
"text": msg,
|
||||
@@ -138,7 +139,7 @@ class Slack extends NotificationProvider {
|
||||
"username": notification.slackusername,
|
||||
"icon_emoji": notification.slackiconemo,
|
||||
};
|
||||
await axios.post(notification.slackwebhookURL, data);
|
||||
await axios.post(notification.slackwebhookURL, data, config);
|
||||
return okMsg;
|
||||
}
|
||||
|
||||
@@ -168,7 +169,7 @@ class Slack extends NotificationProvider {
|
||||
await Slack.deprecateURL(notification.slackbutton);
|
||||
}
|
||||
|
||||
await axios.post(notification.slackwebhookURL, data);
|
||||
await axios.post(notification.slackwebhookURL, data, config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
|
@@ -18,6 +18,7 @@ class SMSPlanet extends NotificationProvider {
|
||||
"content-type": "multipart/form-data"
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
let data = {
|
||||
"from": notification.smsplanetSenderName,
|
||||
|
@@ -18,6 +18,7 @@ class SMSC extends NotificationProvider {
|
||||
"Accept": "text/json",
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
let getArray = [
|
||||
"fmt=3",
|
||||
|
@@ -17,6 +17,7 @@ class SMSEagle extends NotificationProvider {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
let sendMethod;
|
||||
let recipientType;
|
||||
@@ -78,6 +79,7 @@ class SMSEagle extends NotificationProvider {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
let encoding = (notification.smseagleEncoding) ? "unicode" : "standard";
|
||||
let priority = (notification.smseaglePriority) ?? 0;
|
||||
|
@@ -18,7 +18,8 @@ class SMSManager extends NotificationProvider {
|
||||
number: notification.numbers,
|
||||
gateway: notification.messageType,
|
||||
};
|
||||
await axios.get(`${url}?apikey=${data.apikey}&message=${data.message}&number=${data.number}&gateway=${data.messageType}`);
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
await axios.get(`${url}?apikey=${data.apikey}&message=${data.message}&number=${data.number}&gateway=${data.messageType}`, config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
|
@@ -29,6 +29,7 @@ class SMSPartner extends NotificationProvider {
|
||||
"Accept": "application/json",
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
let resp = await axios.post(url, data, config);
|
||||
|
||||
|
@@ -26,7 +26,8 @@ class SpugPush extends NotificationProvider {
|
||||
}
|
||||
}
|
||||
const apiUrl = `https://push.spug.cc/send/${notification.templateKey}`;
|
||||
await axios.post(apiUrl, formData);
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
await axios.post(apiUrl, formData, config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
|
@@ -45,6 +45,7 @@ class Squadcast extends NotificationProvider {
|
||||
}
|
||||
});
|
||||
}
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
await axios.post(notification.squadcastWebhookURL, data, config);
|
||||
return okMsg;
|
||||
|
@@ -31,8 +31,9 @@ class Stackfield extends NotificationProvider {
|
||||
const data = {
|
||||
"Title": textMsg,
|
||||
};
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
|
||||
await axios.post(notification.stackfieldwebhookURL, data);
|
||||
await axios.post(notification.stackfieldwebhookURL, data, config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
|
@@ -185,7 +185,8 @@ class Teams extends NotificationProvider {
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
_sendNotification = async (webhookUrl, payload) => {
|
||||
await axios.post(webhookUrl, payload);
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
await axios.post(webhookUrl, payload, config);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -25,7 +25,8 @@ class TechulusPush extends NotificationProvider {
|
||||
}
|
||||
|
||||
try {
|
||||
await axios.post(`https://push.techulus.com/api/v1/notify/${notification.pushAPIKey}`, data);
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
await axios.post(`https://push.techulus.com/api/v1/notify/${notification.pushAPIKey}`, data, config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
|
@@ -30,9 +30,9 @@ class Telegram extends NotificationProvider {
|
||||
}
|
||||
}
|
||||
|
||||
await axios.get(`${url}/bot${notification.telegramBotToken}/sendMessage`, {
|
||||
params: params,
|
||||
});
|
||||
let config = this.getAxiosConfigWithProxy({ params });
|
||||
|
||||
await axios.get(`${url}/bot${notification.telegramBotToken}/sendMessage`, config);
|
||||
return okMsg;
|
||||
|
||||
} catch (error) {
|
||||
|
@@ -10,12 +10,13 @@ class Threema extends NotificationProvider {
|
||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||
const url = "https://msgapi.threema.ch/send_simple";
|
||||
|
||||
const config = {
|
||||
let config = {
|
||||
headers: {
|
||||
"Accept": "*/*",
|
||||
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8"
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
const data = {
|
||||
from: notification.threemaSenderIdentity,
|
||||
|
@@ -19,6 +19,7 @@ class Twilio extends NotificationProvider {
|
||||
"Authorization": "Basic " + Buffer.from(apiKey + ":" + notification.twilioAuthToken).toString("base64"),
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
let data = new URLSearchParams();
|
||||
data.append("To", notification.twilioToNumber);
|
||||
|
@@ -11,13 +11,14 @@ class WAHA extends NotificationProvider {
|
||||
const okMsg = "Sent Successfully.";
|
||||
|
||||
try {
|
||||
const config = {
|
||||
let config = {
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
"X-Api-Key": notification.wahaApiKey,
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
let data = {
|
||||
"session": notification.wahaSession,
|
||||
|
@@ -41,6 +41,7 @@ class Webhook extends NotificationProvider {
|
||||
}
|
||||
}
|
||||
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
await axios.post(notification.webhookURL, data, config);
|
||||
return okMsg;
|
||||
|
||||
|
@@ -17,6 +17,7 @@ class WeCom extends NotificationProvider {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
let body = this.composeMessage(heartbeatJSON, msg);
|
||||
await axios.post(`https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${notification.weComBotKey}`, body, config);
|
||||
return okMsg;
|
||||
|
@@ -11,13 +11,14 @@ class Whapi extends NotificationProvider {
|
||||
const okMsg = "Sent Successfully.";
|
||||
|
||||
try {
|
||||
const config = {
|
||||
let config = {
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer " + notification.whapiAuthToken,
|
||||
}
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
let data = {
|
||||
"to": notification.whapiRecipient,
|
||||
|
@@ -18,7 +18,8 @@ class WPush extends NotificationProvider {
|
||||
"apikey": notification.wpushAPIkey,
|
||||
"channel": notification.wpushChannel
|
||||
};
|
||||
const result = await axios.post("https://api.wpush.cn/api/v1/send", context);
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
const result = await axios.post("https://api.wpush.cn/api/v1/send", context, config);
|
||||
if (result.data.code !== 0) {
|
||||
throw result.data.message;
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ class YZJ extends NotificationProvider {
|
||||
msg = `${this.statusToString(heartbeatJSON["status"])} ${monitorJSON["name"]} \n> ${heartbeatJSON["msg"]}\n> Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`;
|
||||
}
|
||||
|
||||
const config = {
|
||||
let config = {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
@@ -26,6 +26,7 @@ class YZJ extends NotificationProvider {
|
||||
};
|
||||
// yzjtype=0 => general robot
|
||||
const url = `${notification.yzjWebHookUrl}?yzjtype=0&yzjtoken=${notification.yzjToken}`;
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
const result = await axios.post(url, params, config);
|
||||
if (!result.data?.success) {
|
||||
|
@@ -27,7 +27,8 @@ class ZohoCliq extends NotificationProvider {
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
_sendNotification = async (webhookUrl, payload) => {
|
||||
await axios.post(webhookUrl, { text: payload.join("\n") });
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
await axios.post(webhookUrl, { text: payload.join("\n") }, config);
|
||||
};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user