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:
mamoyal
2025-09-30 13:50:37 +03:00
committed by GitHub
parent f3bbddc287
commit f65aebffb1
75 changed files with 627 additions and 80 deletions

View File

@@ -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;

View File

@@ -30,6 +30,8 @@ class Alerta extends NotificationProvider {
type: "exceptionAlert",
};
config = this.getAxiosConfigWithProxy(config);
if (heartbeatJSON == null) {
let postData = Object.assign({
event: "msg",

View File

@@ -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);

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -18,6 +18,7 @@ class Brevo extends NotificationProvider {
"api-key": notification.brevoApiKey,
},
};
config = this.getAxiosConfigWithProxy(config);
let to = [{ email: notification.brevoToEmail }];

View File

@@ -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);

View File

@@ -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:")) {

View File

@@ -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 + ".";

View File

@@ -60,6 +60,7 @@ class DingDing extends NotificationProvider {
url: `${notification.webHookUrl}&timestamp=${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") {

View File

@@ -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) {

View File

@@ -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,

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -22,6 +22,7 @@ class Kook extends NotificationProvider {
},
};
try {
config = this.getAxiosConfigWithProxy(config);
await axios.post(url, data, config);
return okMsg;

View File

@@ -19,6 +19,7 @@ class Line extends NotificationProvider {
"Authorization": "Bearer " + notification.lineChannelAccessToken
}
};
config = this.getAxiosConfigWithProxy(config);
if (heartbeatJSON == null) {
let testMessage = {
"to": notification.lineUserID,

View File

@@ -20,6 +20,7 @@ class LineNotify extends NotificationProvider {
"Authorization": "Bearer " + notification.lineNotifyAccessToken
}
};
config = this.getAxiosConfigWithProxy(config);
if (heartbeatJSON == null) {
let testMessage = {
"message": msg,

View File

@@ -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;
}

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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,

View File

@@ -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,

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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

View File

@@ -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);

View File

@@ -20,6 +20,7 @@ class Pushbullet extends NotificationProvider {
"Content-Type": "application/json"
}
};
config = this.getAxiosConfigWithProxy(config);
if (heartbeatJSON == null) {
let data = {
"type": "note",

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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),

View File

@@ -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);

View File

@@ -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);

View File

@@ -17,7 +17,7 @@ class SendGrid extends NotificationProvider {
Authorization: `Bearer ${notification.sendgridApiKey}`,
},
};
config = this.getAxiosConfigWithProxy(config);
let personalizations = {
to: [{ email: notification.sendgridToEmail }],
};

View File

@@ -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;

View File

@@ -17,6 +17,7 @@ class SerwerSMS extends NotificationProvider {
"Content-Type": "application/json",
}
};
config = this.getAxiosConfigWithProxy(config);
let data = {
"username": notification.serwersmsUsername,
"password": notification.serwersmsPassword,

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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

View File

@@ -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);

View File

@@ -18,6 +18,7 @@ class SMSPlanet extends NotificationProvider {
"content-type": "multipart/form-data"
}
};
config = this.getAxiosConfigWithProxy(config);
let data = {
"from": notification.smsplanetSenderName,

View File

@@ -18,6 +18,7 @@ class SMSC extends NotificationProvider {
"Accept": "text/json",
}
};
config = this.getAxiosConfigWithProxy(config);
let getArray = [
"fmt=3",

View File

@@ -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;

View File

@@ -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);

View File

@@ -29,6 +29,7 @@ class SMSPartner extends NotificationProvider {
"Accept": "application/json",
}
};
config = this.getAxiosConfigWithProxy(config);
let resp = await axios.post(url, data, config);

View File

@@ -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);

View File

@@ -45,6 +45,7 @@ class Squadcast extends NotificationProvider {
}
});
}
config = this.getAxiosConfigWithProxy(config);
await axios.post(notification.squadcastWebhookURL, data, config);
return okMsg;

View File

@@ -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);

View File

@@ -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);
};
/**

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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,

View File

@@ -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);

View File

@@ -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,

View File

@@ -41,6 +41,7 @@ class Webhook extends NotificationProvider {
}
}
config = this.getAxiosConfigWithProxy(config);
await axios.post(notification.webhookURL, data, config);
return okMsg;

View File

@@ -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;

View File

@@ -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,

View File

@@ -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;
}

View File

@@ -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) {

View File

@@ -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);
};
/**