mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-09-30 11:39:21 +08:00
feat: Add Brevo notification provider (#6150)
Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
62
server/notification-providers/brevo.js
Normal file
62
server/notification-providers/brevo.js
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
const NotificationProvider = require("./notification-provider");
|
||||||
|
const axios = require("axios");
|
||||||
|
|
||||||
|
class Brevo extends NotificationProvider {
|
||||||
|
name = "Brevo";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||||
|
const okMsg = "Sent Successfully.";
|
||||||
|
|
||||||
|
try {
|
||||||
|
let config = {
|
||||||
|
headers: {
|
||||||
|
"Accept": "application/json",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"api-key": notification.brevoApiKey,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
let to = [{ email: notification.brevoToEmail }];
|
||||||
|
|
||||||
|
let data = {
|
||||||
|
sender: {
|
||||||
|
email: notification.brevoFromEmail.trim(),
|
||||||
|
name: notification.brevoFromName || "Uptime Kuma"
|
||||||
|
},
|
||||||
|
to: to,
|
||||||
|
subject: notification.brevoSubject || "Notification from Your Uptime Kuma",
|
||||||
|
htmlContent: `<html><head></head><body><p>${msg.replace(/\n/g, "<br>")}</p></body></html>`
|
||||||
|
};
|
||||||
|
|
||||||
|
if (notification.brevoCcEmail) {
|
||||||
|
data.cc = notification.brevoCcEmail
|
||||||
|
.split(",")
|
||||||
|
.map((email) => ({ email: email.trim() }));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (notification.brevoBccEmail) {
|
||||||
|
data.bcc = notification.brevoBccEmail
|
||||||
|
.split(",")
|
||||||
|
.map((email) => ({ email: email.trim() }));
|
||||||
|
}
|
||||||
|
|
||||||
|
let result = await axios.post(
|
||||||
|
"https://api.brevo.com/v3/smtp/email",
|
||||||
|
data,
|
||||||
|
config
|
||||||
|
);
|
||||||
|
if (result.status === 201) {
|
||||||
|
return okMsg;
|
||||||
|
} else {
|
||||||
|
throw new Error(`Unexpected status code: ${result.status}`);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
this.throwGeneralAxiosError(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Brevo;
|
@@ -75,6 +75,7 @@ const Cellsynt = require("./notification-providers/cellsynt");
|
|||||||
const Onesender = require("./notification-providers/onesender");
|
const Onesender = require("./notification-providers/onesender");
|
||||||
const Wpush = require("./notification-providers/wpush");
|
const Wpush = require("./notification-providers/wpush");
|
||||||
const SendGrid = require("./notification-providers/send-grid");
|
const SendGrid = require("./notification-providers/send-grid");
|
||||||
|
const Brevo = require("./notification-providers/brevo");
|
||||||
const YZJ = require("./notification-providers/yzj");
|
const YZJ = require("./notification-providers/yzj");
|
||||||
const SMSPlanet = require("./notification-providers/sms-planet");
|
const SMSPlanet = require("./notification-providers/sms-planet");
|
||||||
const SpugPush = require("./notification-providers/spugpush");
|
const SpugPush = require("./notification-providers/spugpush");
|
||||||
@@ -169,6 +170,7 @@ class Notification {
|
|||||||
new Cellsynt(),
|
new Cellsynt(),
|
||||||
new Wpush(),
|
new Wpush(),
|
||||||
new SendGrid(),
|
new SendGrid(),
|
||||||
|
new Brevo(),
|
||||||
new YZJ(),
|
new YZJ(),
|
||||||
new SMSPlanet(),
|
new SMSPlanet(),
|
||||||
new SpugPush(),
|
new SpugPush(),
|
||||||
|
@@ -170,6 +170,7 @@ export default {
|
|||||||
"gtxmessaging": "GtxMessaging",
|
"gtxmessaging": "GtxMessaging",
|
||||||
"Cellsynt": "Cellsynt",
|
"Cellsynt": "Cellsynt",
|
||||||
"SendGrid": "SendGrid",
|
"SendGrid": "SendGrid",
|
||||||
|
"Brevo": "Brevo",
|
||||||
"notifery": "Notifery"
|
"notifery": "Notifery"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
58
src/components/notifications/Brevo.vue
Normal file
58
src/components/notifications/Brevo.vue
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<template>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="brevo-api-key" class="form-label">{{ $t("brevoApiKey") }}</label>
|
||||||
|
<HiddenInput id="brevo-api-key" v-model="$parent.notification.brevoApiKey" :required="true" autocomplete="new-password"></HiddenInput>
|
||||||
|
<i18n-t tag="div" keypath="brevoApiHelp" class="form-text">
|
||||||
|
<a href="https://app.brevo.com/settings/keys/api" target="_blank">https://app.brevo.com/settings/keys/api</a>
|
||||||
|
</i18n-t>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="brevo-from-email" class="form-label">{{ $t("brevoFromEmail") }}</label>
|
||||||
|
<input id="brevo-from-email" v-model="$parent.notification.brevoFromEmail" type="text" class="form-control" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="brevo-from-name" class="form-label">{{ $t("brevoFromName") }}</label>
|
||||||
|
<input id="brevo-from-name" v-model="$parent.notification.brevoFromName" type="text" class="form-control">
|
||||||
|
<div class="form-text">{{ $t("brevoLeaveBlankForDefaultName") }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="brevo-to-email" class="form-label">{{ $t("brevoToEmail") }}</label>
|
||||||
|
<input id="brevo-to-email" v-model="$parent.notification.brevoToEmail" type="text" class="form-control" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="brevo-cc-email" class="form-label">{{ $t("brevoCcEmail") }}</label>
|
||||||
|
<input id="brevo-cc-email" v-model="$parent.notification.brevoCcEmail" type="text" class="form-control">
|
||||||
|
<div class="form-text">{{ $t("brevoSeparateMultipleEmails") }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="brevo-bcc-email" class="form-label">{{ $t("brevoBccEmail") }}</label>
|
||||||
|
<input id="brevo-bcc-email" v-model="$parent.notification.brevoBccEmail" type="text" class="form-control">
|
||||||
|
<small class="form-text text-muted">{{ $t("brevoSeparateMultipleEmails") }}</small>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="brevo-subject" class="form-label">{{ $t("brevoSubject") }}</label>
|
||||||
|
<input id="brevo-subject" v-model="$parent.notification.brevoSubject" type="text" class="form-control">
|
||||||
|
<small class="form-text text-muted">{{ $t("brevoLeaveBlankForDefaultSubject") }}</small>
|
||||||
|
</div>
|
||||||
|
<i18n-t tag="p" keypath="More info on:" style="margin-top: 8px;">
|
||||||
|
<a href="https://developers.brevo.com/reference/sendtransacemail" target="_blank">https://developers.brevo.com/reference/sendtransacemail</a>
|
||||||
|
</i18n-t>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import HiddenInput from "../HiddenInput.vue";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
HiddenInput,
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
if (typeof this.$parent.notification.brevoSubject === "undefined") {
|
||||||
|
this.$parent.notification.brevoSubject = "Notification from Your Uptime Kuma";
|
||||||
|
}
|
||||||
|
if (typeof this.$parent.notification.brevoFromName === "undefined") {
|
||||||
|
this.$parent.notification.brevoFromName = "Uptime Kuma";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
@@ -74,6 +74,7 @@ import Cellsynt from "./Cellsynt.vue";
|
|||||||
import WPush from "./WPush.vue";
|
import WPush from "./WPush.vue";
|
||||||
import SIGNL4 from "./SIGNL4.vue";
|
import SIGNL4 from "./SIGNL4.vue";
|
||||||
import SendGrid from "./SendGrid.vue";
|
import SendGrid from "./SendGrid.vue";
|
||||||
|
import Brevo from "./Brevo.vue";
|
||||||
import YZJ from "./YZJ.vue";
|
import YZJ from "./YZJ.vue";
|
||||||
import SMSPlanet from "./SMSPlanet.vue";
|
import SMSPlanet from "./SMSPlanet.vue";
|
||||||
|
|
||||||
@@ -158,6 +159,7 @@ const NotificationFormList = {
|
|||||||
"Cellsynt": Cellsynt,
|
"Cellsynt": Cellsynt,
|
||||||
"WPush": WPush,
|
"WPush": WPush,
|
||||||
"SendGrid": SendGrid,
|
"SendGrid": SendGrid,
|
||||||
|
"Brevo": Brevo,
|
||||||
"YZJ": YZJ,
|
"YZJ": YZJ,
|
||||||
"SMSPlanet": SMSPlanet,
|
"SMSPlanet": SMSPlanet,
|
||||||
};
|
};
|
||||||
|
@@ -1100,6 +1100,17 @@
|
|||||||
"rabbitmqHelpText": "To use the monitor, you will need to enable the Management Plugin in your RabbitMQ setup. For more information, please consult the {rabitmq_documentation}.",
|
"rabbitmqHelpText": "To use the monitor, you will need to enable the Management Plugin in your RabbitMQ setup. For more information, please consult the {rabitmq_documentation}.",
|
||||||
"SendGrid API Key": "SendGrid API Key",
|
"SendGrid API Key": "SendGrid API Key",
|
||||||
"Separate multiple email addresses with commas": "Separate multiple email addresses with commas",
|
"Separate multiple email addresses with commas": "Separate multiple email addresses with commas",
|
||||||
|
"brevoApiKey": "Brevo API Key",
|
||||||
|
"brevoApiHelp": "Create an API key here: {0}",
|
||||||
|
"brevoFromEmail": "From Email",
|
||||||
|
"brevoFromName": "From Name",
|
||||||
|
"brevoLeaveBlankForDefaultName": "leave blank for default name",
|
||||||
|
"brevoToEmail": "To Email",
|
||||||
|
"brevoCcEmail": "CC Email",
|
||||||
|
"brevoBccEmail": "BCC Email",
|
||||||
|
"brevoSeparateMultipleEmails": "Separate multiple email addresses with commas",
|
||||||
|
"brevoSubject": "Subject",
|
||||||
|
"brevoLeaveBlankForDefaultSubject": "leave blank for default subject",
|
||||||
"pingCountLabel": "Max Packets",
|
"pingCountLabel": "Max Packets",
|
||||||
"pingCountDescription": "Number of packets to send before stopping",
|
"pingCountDescription": "Number of packets to send before stopping",
|
||||||
"pingNumericLabel": "Numeric Output",
|
"pingNumericLabel": "Numeric Output",
|
||||||
|
Reference in New Issue
Block a user