mirror of
https://github.com/louislam/uptime-kuma.git
synced 2026-01-31 11:03:11 +08:00
Merge branch 'master' into feature/mssql-monitor
This commit is contained in:
1414
package-lock.json
generated
1414
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
48
server/notification-providers/resend.js
Normal file
48
server/notification-providers/resend.js
Normal file
@@ -0,0 +1,48 @@
|
||||
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.resendApiKey}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
const email = notification.resendFromEmail.trim();
|
||||
|
||||
const fromName = notification.resendFromName?.trim() || "Uptime Kuma";
|
||||
let data = {
|
||||
from: `${fromName} <${email}>`,
|
||||
to: notification.resendToEmail,
|
||||
subject: notification.resendSubject || "Notification from Your Uptime Kuma",
|
||||
// supplied text directly instead of html
|
||||
text: msg,
|
||||
};
|
||||
|
||||
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;
|
||||
@@ -77,6 +77,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");
|
||||
@@ -174,6 +175,7 @@ class Notification {
|
||||
new Cellsynt(),
|
||||
new Wpush(),
|
||||
new Brevo(),
|
||||
new Resend(),
|
||||
new YZJ(),
|
||||
new SMSPlanet(),
|
||||
new SpugPush(),
|
||||
|
||||
@@ -172,6 +172,7 @@ export default {
|
||||
"Cellsynt": "Cellsynt",
|
||||
"SendGrid": "SendGrid",
|
||||
"Brevo": "Brevo",
|
||||
"Resend": "Resend",
|
||||
"notifery": "Notifery",
|
||||
"Webpush": "Webpush",
|
||||
};
|
||||
|
||||
48
src/components/notifications/Resend.vue
Normal file
48
src/components/notifications/Resend.vue
Normal 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>
|
||||
@@ -80,6 +80,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.
|
||||
@@ -165,6 +166,7 @@ const NotificationFormList = {
|
||||
"WPush": WPush,
|
||||
"SendGrid": SendGrid,
|
||||
"Brevo": Brevo,
|
||||
"Resend": Resend,
|
||||
"YZJ": YZJ,
|
||||
"SMSPlanet": SMSPlanet,
|
||||
"Webpush": Webpush,
|
||||
|
||||
@@ -1183,6 +1183,13 @@
|
||||
"brevoSeparateMultipleEmails": "Separate multiple email addresses with commas",
|
||||
"brevoSubject": "Subject",
|
||||
"brevoLeaveBlankForDefaultSubject": "leave blank for default subject",
|
||||
"resendApiKey": "Resend API Key",
|
||||
"resendApiHelp": "Create an api key here {0}",
|
||||
"resendFromName": "From Name",
|
||||
"resendFromEmail": "From Email",
|
||||
"resendLeaveBlankForDefaultName": "leave blank for default name",
|
||||
"resendToEmail": "To Email",
|
||||
"resendSubject": "Subject",
|
||||
"pingCountLabel": "Max Packets",
|
||||
"pingCountDescription": "Number of packets to send before stopping",
|
||||
"pingNumericLabel": "Numeric Output",
|
||||
|
||||
Reference in New Issue
Block a user