Files
Brian Pravato 7188e054d8
Automatically close stale issues / stale (push) Has been cancelled
Nightly Release / release-nightly (push) Has been cancelled
Auto Test / auto-test (20, macos-latest) (push) Has been cancelled
Auto Test / auto-test (20, ubuntu-22.04) (push) Has been cancelled
Auto Test / auto-test (20, ubuntu-22.04-arm) (push) Has been cancelled
Auto Test / auto-test (20, windows-latest) (push) Has been cancelled
Auto Test / auto-test (24, macos-latest) (push) Has been cancelled
Auto Test / auto-test (24, ubuntu-22.04) (push) Has been cancelled
Auto Test / auto-test (24, ubuntu-22.04-arm) (push) Has been cancelled
Auto Test / auto-test (24, windows-latest) (push) Has been cancelled
Auto Test / auto-test (25, ubuntu-22.04) (push) Has been cancelled
Auto Test / armv7-simple-test (20) (push) Has been cancelled
Auto Test / armv7-simple-test (22) (push) Has been cancelled
Auto Test / check-linters (push) Has been cancelled
Auto Test / e2e-test (push) Has been cancelled
autofix.ci / autofix (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL / zizmor (push) Has been cancelled
Merge Conflict Labeler / Labeling (push) Has been cancelled
validate / json-yaml-validate (push) Has been cancelled
validate / validate (push) Has been cancelled
NPM Update / npm-update (push) Has been cancelled
feat(notification): add custom message template support for Evolution provider (#7207)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Frank Elsinga <frank@elsinga.de>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-27 20:57:18 +01:00

49 lines
1.5 KiB
JavaScript

const NotificationProvider = require("./notification-provider");
const axios = require("axios");
class Evolution extends NotificationProvider {
name = "evolution";
/**
* @inheritdoc
*/
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
const okMsg = "Sent Successfully.";
try {
let config = {
headers: {
Accept: "application/json",
"Content-Type": "application/json",
apikey: notification.evolutionAuthToken,
},
};
config = this.getAxiosConfigWithProxy(config);
let text = msg;
const customMessage = notification.evolutionCustomMessage;
if (notification.evolutionUseCustomMessage && typeof customMessage === "string" && customMessage.trim()) {
text = await this.renderTemplate(customMessage, msg, monitorJSON, heartbeatJSON);
}
let data = {
number: notification.evolutionRecipient,
text,
};
let url =
(notification.evolutionApiUrl || "https://evolapicloud.com/").replace(/([^/])\/+$/, "$1") +
"/message/sendText/" +
encodeURIComponent(notification.evolutionInstanceName);
await axios.post(url, data, config);
return okMsg;
} catch (error) {
this.throwGeneralAxiosError(error);
}
}
}
module.exports = Evolution;