Added the notification provider

This commit is contained in:
lsnnt 2025-12-30 12:30:26 +05:30
parent fbbeeff22a
commit 7578f55b94
5 changed files with 102 additions and 0 deletions

View File

@ -0,0 +1,49 @@
const NotificationProvider = require("./notification-provider");
const axios = require("axios");
class Resend extends NotificationProvider {
name = "Resend";
/**
* @inheritdoc
*/
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
const okMsg = "Sent Successfully.";
try {
let config = {
headers: {
Authorization: `Bearer ${notification.longLivedAccessToken}`,
"Content-Type": "application/json",
},
};
config = this.getAxiosConfigWithProxy(config);
const email = notification.resendFromEmail.trim();
const fromName = notification.resendFromName?.trim()
? notification.resendFromName.trim()
: "Uptime Kuma";
let data = {
from: `${fromName} <${email}>`,
to: notification.resendToEmail,
subject: notification.resendSubject || "Notification from Your Uptime Kuma",
html: `<html><head></head><body><p>${msg.replace(/\n/g, "<br>")}</p></body></html>`
};
let result = await axios.post(
"https://api.resend.com/emails",
data,
config
);
if (result.status === 200) {
return okMsg;
} else {
throw new Error(`Unexpected status code: ${result.status}`);
}
} catch (error) {
this.throwGeneralAxiosError(error);
}
}
}
module.exports = Resend;

View File

@ -78,6 +78,7 @@ const Onesender = require("./notification-providers/onesender");
const Wpush = require("./notification-providers/wpush");
const SendGrid = require("./notification-providers/send-grid");
const Brevo = require("./notification-providers/brevo");
const Resend = require("./notification-providers/resend");
const YZJ = require("./notification-providers/yzj");
const SMSPlanet = require("./notification-providers/sms-planet");
const SpugPush = require("./notification-providers/spugpush");
@ -176,6 +177,7 @@ class Notification {
new Cellsynt(),
new Wpush(),
new Brevo(),
new Resend(),
new YZJ(),
new SMSPlanet(),
new SpugPush(),

View File

@ -173,6 +173,7 @@ export default {
"Cellsynt": "Cellsynt",
"SendGrid": "SendGrid",
"Brevo": "Brevo",
"Resend": "Resend",
"notifery": "Notifery",
"Webpush": "Webpush",
};

View File

@ -0,0 +1,48 @@
<template>
<div class="mb-3">
<label for="resend-api-key" class="form-label">{{ $t("resendApiKey") }}</label>
<HiddenInput id="resend-api-key" v-model="$parent.notification.resendApiKey" :required="true" autocomplete="new-password"></HiddenInput>
<i18n-t tag="div" keypath="resendApiHelp" class="form-text">
<a href="https://resend.com/api-keys" target="_blank">https://resend.com/api-keys</a>
</i18n-t>
</div>
<div class="mb-3">
<label for="resend-from-email" class="form-label">{{ $t("resendFromEmail") }}</label>
<input id="resend-from-email" v-model="$parent.notification.resendFromEmail" type="text" class="form-control" required>
</div>
<div class="mb-3">
<label for="resend-from-name" class="form-label">{{ $t("resendFromName") }}</label>
<input id="resend-from-name" v-model="$parent.notification.resendFromName" type="text" class="form-control">
<div class="form-text">{{ $t("resendLeaveBlankForDefaultName") }}</div>
</div>
<div class="mb-3">
<label for="resend-to-email" class="form-label">{{ $t("resendToEmail") }}</label>
<input id="resend-to-email" v-model="$parent.notification.resendToEmail" type="text" class="form-control" required>
</div>
<div class="mb-3">
<label for="resend-subject" class="form-label">{{ $t("resendSubject") }}</label>
<input id="resend-subject" v-model="$parent.notification.resendSubject" type="text" class="form-control">
<small class="form-text text-muted">{{ $t("resendLeaveBlankForDefaultSubject") }}</small>
</div>
<i18n-t tag="p" keypath="More info on:" style="margin-top: 8px;">
<a href="https://resend.com/docs/dashboard/emails/introduction" target="_blank">https://resend.com/docs/dashboard/emails/introduction</a>
</i18n-t>
</template>
<script>
import HiddenInput from "../HiddenInput.vue";
export default {
components: {
HiddenInput,
},
mounted() {
if (typeof this.$parent.notification.resendSubject === "undefined") {
this.$parent.notification.resendSubject = "Notification from Your Uptime Kuma";
}
if (typeof this.$parent.notification.resendFromName === "undefined") {
this.$parent.notification.resendFromName = "Uptime Kuma";
}
},
};
</script>

View File

@ -81,6 +81,7 @@ import YZJ from "./YZJ.vue";
import SMSPlanet from "./SMSPlanet.vue";
import SMSIR from "./SMSIR.vue";
import Webpush from "./Webpush.vue";
import Resend from "./Resend.vue";
/**
* Manage all notification form.
@ -167,6 +168,7 @@ const NotificationFormList = {
"WPush": WPush,
"SendGrid": SendGrid,
"Brevo": Brevo,
"Resend":Resend,
"YZJ": YZJ,
"SMSPlanet": SMSPlanet,
"Webpush": Webpush,