mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-13 17:14:21 -08:00
92e982a910
Some checks failed
Auto Test / check-linters (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Merge Conflict Labeler / Labeling (push) Has been cancelled
json-yaml-validate / json-yaml-validate (push) Has been cancelled
Auto Test / auto-test (18, ARM64) (push) Has been cancelled
Auto Test / auto-test (18, macos-latest) (push) Has been cancelled
Auto Test / auto-test (18, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (18, windows-latest) (push) Has been cancelled
Auto Test / auto-test (20.5, ARM64) (push) Has been cancelled
Auto Test / auto-test (20.5, macos-latest) (push) Has been cancelled
Auto Test / auto-test (20.5, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (20.5, windows-latest) (push) Has been cancelled
Auto Test / armv7-simple-test (18, ARMv7) (push) Has been cancelled
Auto Test / armv7-simple-test (20, ARMv7) (push) Has been cancelled
Auto Test / e2e-test (push) Has been cancelled
Co-authored-by: Frank Elsinga <[email protected]>
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
const NotificationProvider = require("./notification-provider");
|
|
const axios = require("axios");
|
|
|
|
class Onesender extends NotificationProvider {
|
|
name = "Onesender";
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
|
const okMsg = "Sent Successfully.";
|
|
|
|
try {
|
|
let data = {
|
|
heartbeat: heartbeatJSON,
|
|
monitor: monitorJSON,
|
|
msg,
|
|
to: notification.onesenderReceiver,
|
|
type: "text",
|
|
recipient_type: "individual",
|
|
text: {
|
|
body: msg
|
|
}
|
|
};
|
|
if (notification.onesenderTypeReceiver === "private") {
|
|
data.to = notification.onesenderReceiver + "@s.whatsapp.net";
|
|
} else {
|
|
data.recipient_type = "group";
|
|
data.to = notification.onesenderReceiver + "@g.us";
|
|
}
|
|
let config = {
|
|
headers: {
|
|
"Authorization": "Bearer " + notification.onesenderToken,
|
|
}
|
|
};
|
|
await axios.post(notification.onesenderURL, data, config);
|
|
return okMsg;
|
|
|
|
} catch (error) {
|
|
this.throwGeneralAxiosError(error);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = Onesender;
|