Merge branch 'master' into status-page-default-locale

pull/595/head
LouisLam 3 years ago
commit 288e87bb3d

@ -7,7 +7,7 @@ class Discord extends NotificationProvider {
name = "discord"; name = "discord";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully. "; let okMsg = "Sent Successfully.";
try { try {
const discordDisplayName = notification.discordUsername || "Uptime Kuma"; const discordDisplayName = notification.discordUsername || "Uptime Kuma";

@ -6,7 +6,7 @@ class Gotify extends NotificationProvider {
name = "gotify"; name = "gotify";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully. "; let okMsg = "Sent Successfully.";
try { try {
if (notification.gotifyserverurl && notification.gotifyserverurl.endsWith("/")) { if (notification.gotifyserverurl && notification.gotifyserverurl.endsWith("/")) {
notification.gotifyserverurl = notification.gotifyserverurl.slice(0, -1); notification.gotifyserverurl = notification.gotifyserverurl.slice(0, -1);

@ -7,7 +7,7 @@ class Line extends NotificationProvider {
name = "line"; name = "line";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully. "; let okMsg = "Sent Successfully.";
try { try {
let lineAPIUrl = "https://api.line.me/v2/bot/message/push"; let lineAPIUrl = "https://api.line.me/v2/bot/message/push";
let config = { let config = {

@ -7,7 +7,7 @@ class LunaSea extends NotificationProvider {
name = "lunasea"; name = "lunasea";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully. "; let okMsg = "Sent Successfully.";
let lunaseadevice = "https://notify.lunasea.app/v1/custom/device/" + notification.lunaseaDevice let lunaseadevice = "https://notify.lunasea.app/v1/custom/device/" + notification.lunaseaDevice
try { try {

@ -0,0 +1,45 @@
const NotificationProvider = require("./notification-provider");
const axios = require("axios");
const Crypto = require("crypto");
const { debug } = require("../../src/util");
class Matrix extends NotificationProvider {
name = "matrix";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully.";
const size = 20;
const randomString = encodeURIComponent(
Crypto
.randomBytes(size)
.toString("base64")
.slice(0, size)
);
debug("Random String: " + randomString);
const roomId = encodeURIComponent(notification.internalRoomId);
debug("Matrix Room ID: " + roomId);
try {
let config = {
headers: {
"Authorization": `Bearer ${notification.accessToken}`,
}
};
let data = {
"msgtype": "m.text",
"body": msg
};
await axios.put(`${notification.homeserverUrl}/_matrix/client/r0/rooms/${roomId}/send/m.room.message/${randomString}`, data, config);
return okMsg;
} catch (error) {
this.throwGeneralAxiosError(error);
}
}
}
module.exports = Matrix;

@ -7,7 +7,7 @@ class Mattermost extends NotificationProvider {
name = "mattermost"; name = "mattermost";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully. "; let okMsg = "Sent Successfully.";
try { try {
const mattermostUserName = notification.mattermostusername || "Uptime Kuma"; const mattermostUserName = notification.mattermostusername || "Uptime Kuma";
// If heartbeatJSON is null, assume we're testing. // If heartbeatJSON is null, assume we're testing.

@ -6,30 +6,54 @@ class Octopush extends NotificationProvider {
name = "octopush"; name = "octopush";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully. "; let okMsg = "Sent Successfully.";
try { try {
let config = { // Default - V2
headers: { if (notification.octopushVersion == 2 || !notification.octopushVersion) {
"api-key": notification.octopushAPIKey, let config = {
"api-login": notification.octopushLogin, headers: {
"cache-control": "no-cache" "api-key": notification.octopushAPIKey,
} "api-login": notification.octopushLogin,
}; "cache-control": "no-cache"
let data = {
"recipients": [
{
"phone_number": notification.octopushPhoneNumber
} }
], };
//octopush not supporting non ascii char let data = {
"text": msg.replace(/[^\x00-\x7F]/g, ""), "recipients": [
"type": notification.octopushSMSType, {
"purpose": "alert", "phone_number": notification.octopushPhoneNumber
"sender": notification.octopushSenderName }
}; ],
//octopush not supporting non ascii char
"text": msg.replace(/[^\x00-\x7F]/g, ""),
"type": notification.octopushSMSType,
"purpose": "alert",
"sender": notification.octopushSenderName
};
await axios.post("https://api.octopush.com/v1/public/sms-campaign/send", data, config)
} else if (notification.octopushVersion == 1) {
let data = {
"user_login": notification.octopushDMLogin,
"api_key": notification.octopushDMAPIKey,
"sms_recipients": notification.octopushDMPhoneNumber,
"sms_sender": notification.octopushDMSenderName,
"sms_type": (notification.octopushDMSMSType == "sms_premium") ? "FR" : "XXX",
"transactional": "1",
//octopush not supporting non ascii char
"sms_text": msg.replace(/[^\x00-\x7F]/g, ""),
};
let config = {
headers: {
"cache-control": "no-cache"
},
params: data
};
await axios.post("https://www.octopush-dm.com/api/sms/json", {}, config)
} else {
throw new Error("Unknown Octopush version!");
}
await axios.post("https://api.octopush.com/v1/public/sms-campaign/send", data, config)
return okMsg; return okMsg;
} catch (error) { } catch (error) {
this.throwGeneralAxiosError(error); this.throwGeneralAxiosError(error);

@ -8,7 +8,7 @@ class Pushbullet extends NotificationProvider {
name = "pushbullet"; name = "pushbullet";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully. "; let okMsg = "Sent Successfully.";
try { try {
let pushbulletUrl = "https://api.pushbullet.com/v2/pushes"; let pushbulletUrl = "https://api.pushbullet.com/v2/pushes";

@ -6,7 +6,7 @@ class Pushover extends NotificationProvider {
name = "pushover"; name = "pushover";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully. "; let okMsg = "Sent Successfully.";
let pushoverlink = "https://api.pushover.net/1/messages.json" let pushoverlink = "https://api.pushover.net/1/messages.json"
try { try {

@ -6,7 +6,7 @@ class Pushy extends NotificationProvider {
name = "pushy"; name = "pushy";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully. "; let okMsg = "Sent Successfully.";
try { try {
await axios.post(`https://api.pushy.me/push?api_key=${notification.pushyAPIKey}`, { await axios.post(`https://api.pushy.me/push?api_key=${notification.pushyAPIKey}`, {

@ -9,7 +9,7 @@ class RocketChat extends NotificationProvider {
name = "rocket.chat"; name = "rocket.chat";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully. "; let okMsg = "Sent Successfully.";
try { try {
if (heartbeatJSON == null) { if (heartbeatJSON == null) {
let data = { let data = {

@ -6,7 +6,7 @@ class Signal extends NotificationProvider {
name = "signal"; name = "signal";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully. "; let okMsg = "Sent Successfully.";
try { try {
let data = { let data = {

@ -25,7 +25,7 @@ class Slack extends NotificationProvider {
} }
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully. "; let okMsg = "Sent Successfully.";
try { try {
if (heartbeatJSON == null) { if (heartbeatJSON == null) {
let data = { let data = {

@ -87,7 +87,7 @@ class Teams extends NotificationProvider {
}; };
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully. "; let okMsg = "Sent Successfully.";
try { try {
if (heartbeatJSON == null) { if (heartbeatJSON == null) {

@ -6,7 +6,7 @@ class Telegram extends NotificationProvider {
name = "telegram"; name = "telegram";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully. "; let okMsg = "Sent Successfully.";
try { try {
await axios.get(`https://api.telegram.org/bot${notification.telegramBotToken}/sendMessage`, { await axios.get(`https://api.telegram.org/bot${notification.telegramBotToken}/sendMessage`, {

@ -7,7 +7,7 @@ class Webhook extends NotificationProvider {
name = "webhook"; name = "webhook";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully. "; let okMsg = "Sent Successfully.";
try { try {
let data = { let data = {

@ -5,6 +5,7 @@ const Gotify = require("./notification-providers/gotify");
const Line = require("./notification-providers/line"); const Line = require("./notification-providers/line");
const LunaSea = require("./notification-providers/lunasea"); const LunaSea = require("./notification-providers/lunasea");
const Mattermost = require("./notification-providers/mattermost"); const Mattermost = require("./notification-providers/mattermost");
const Matrix = require("./notification-providers/matrix");
const Octopush = require("./notification-providers/octopush"); const Octopush = require("./notification-providers/octopush");
const Pushbullet = require("./notification-providers/pushbullet"); const Pushbullet = require("./notification-providers/pushbullet");
const Pushover = require("./notification-providers/pushover"); const Pushover = require("./notification-providers/pushover");
@ -34,6 +35,7 @@ class Notification {
new Line(), new Line(),
new LunaSea(), new LunaSea(),
new Mattermost(), new Mattermost(),
new Matrix(),
new Octopush(), new Octopush(),
new Pushbullet(), new Pushbullet(),
new Pushover(), new Pushover(),

@ -11,18 +11,18 @@ export default {
computed: { computed: {
color() { color() {
if (this.status === 0) { if (this.status === 0) {
return "danger" return "danger";
} }
if (this.status === 1) { if (this.status === 1) {
return "primary" return "primary";
} }
if (this.status === 2) { if (this.status === 2) {
return "warning" return "warning";
} }
return "secondary" return "secondary";
}, },
text() { text() {
@ -41,11 +41,11 @@ export default {
return this.$t("Unknown"); return this.$t("Unknown");
}, },
}, },
} };
</script> </script>
<style scoped> <style scoped>
span { span {
width: 64px; min-width: 64px;
} }
</style> </style>

@ -0,0 +1,34 @@
<template>
<div class="mb-3">
<label for="homeserver-url" class="form-label">Homeserver URL (with http(s):// and optionally port)</label><span style="color: red;"><sup>*</sup></span>
<input id="homeserver-url" v-model="$parent.notification.homeserverUrl" type="text" class="form-control" :required="true">
</div>
<div class="mb-3">
<label for="internal-room-id" class="form-label">Internal Room Id</label><span style="color: red;"><sup>*</sup></span>
<input id="internal-room-id" v-model="$parent.notification.internalRoomId" type="text" class="form-control" required="true">
</div>
<div class="mb-3">
<label for="access-token" class="form-label">Access Token</label><span style="color: red;"><sup>*</sup></span>
<HiddenInput id="access-token" v-model="$parent.notification.accessToken" :required="true" autocomplete="one-time-code" :maxlength="500"></HiddenInput>
</div>
<div class="form-text">
<span style="color: red;"><sup>*</sup></span>Required
<p style="margin-top: 8px;">
You can find the internal room ID by looking in the advanced section of the room settings in your Matrix client. It should look like !QMdRCpUIfLwsfjxye6:home.server.
</p>
<p style="margin-top: 8px;">
It is highly recommended you create a new user and do not use your own Matrix user's access token as it will allow full access to your account and all the rooms you joined. Instead, create a new user and only invite it to the room that you want to receive the notification in. You can get the access token by running <code>curl -XPOST -d '{"type": "m.login.password", "identifier": {"user": "botusername", "type": "m.id.user"}, "password": "passwordforuser"}' "https://home.server/_matrix/client/r0/login"</code>.
</p>
</div>
</template>
<script>
import HiddenInput from "../HiddenInput.vue";
export default {
components: {
HiddenInput,
},
}
</script>

@ -1,4 +1,14 @@
<template> <template>
<div class="mb-3">
<label for="octopush-version" class="form-label">Octopush API Version</label>
<select id="octopush-version" v-model="$parent.notification.octopushVersion" class="form-select">
<option value="2">Octopush (endpoint: api.octopush.com)</option>
<option value="1">Legacy Octopush-DM (endpoint: www.octopush-dm.com)</option>
</select>
<div class="form-text">
Do you use the legacy version of Octopush (2011-2020) or the new version?
</div>
</div>
<div class="mb-3"> <div class="mb-3">
<label for="octopush-key" class="form-label">API KEY</label> <label for="octopush-key" class="form-label">API KEY</label>
<HiddenInput id="octopush-key" v-model="$parent.notification.octopushAPIKey" :required="true" autocomplete="one-time-code"></HiddenInput> <HiddenInput id="octopush-key" v-model="$parent.notification.octopushAPIKey" :required="true" autocomplete="one-time-code"></HiddenInput>

@ -15,6 +15,7 @@ import Apprise from "./Apprise.vue";
import Pushbullet from "./Pushbullet.vue"; import Pushbullet from "./Pushbullet.vue";
import Line from "./Line.vue"; import Line from "./Line.vue";
import Mattermost from "./Mattermost.vue"; import Mattermost from "./Mattermost.vue";
import Matrix from "./Matrix.vue";
/** /**
* Manage all notification form. * Manage all notification form.
@ -38,7 +39,8 @@ const NotificationFormList = {
"apprise": Apprise, "apprise": Apprise,
"pushbullet": Pushbullet, "pushbullet": Pushbullet,
"line": Line, "line": Line,
"mattermost": Mattermost "mattermost": Mattermost,
"matrix": Matrix,
} }
export default NotificationFormList export default NotificationFormList

@ -240,5 +240,38 @@ export default {
pushbullet: "Pushbullet", pushbullet: "Pushbullet",
line: "Line Messenger", line: "Line Messenger",
mattermost: "Mattermost", mattermost: "Mattermost",
"User Key": "User Key",
"Device": "Device",
"Message Title": "Message Title",
"Notification Sound": "Notification Sound",
"More info on:": "More info on: {0}",
pushoverDesc1: "Emergency priority (2) has default 30 second timeout between retries and will expire after 1 hour.",
pushoverDesc2: "If you want to send notifications to different devices, fill out Device field.",
"SMS Type": "SMS Type",
octopushTypePremium: "Premium (Fast - recommended for alerting)",
octopushTypeLowCost: "Low Cost (Slow, sometimes blocked by operator)",
"Check octopush prices": "Check octopush prices {0}.",
octopushPhoneNumber: "Phone number (intl format, eg : +33612345678) ",
octopushSMSSender: "SMS Sender Name : 3-11 alphanumeric characters and space (a-zA-Z0-9)",
"LunaSea Device ID": "LunaSea Device ID",
"Apprise URL": "Apprise URL",
"Example:": "Example: {0}",
"Read more:": "Read more: {0}",
"Status:": "Status: {0}",
"Read more": "Read more",
appriseInstalled: "Apprise is installed.",
appriseNotInstalled: "Apprise is not installed. {0}",
"Access Token": "Access Token",
"Channel access token": "Channel access token",
"Line Developers Console": "Line Developers Console",
lineDevConsoleTo: "Line Developers Console - {0}",
"Basic Settings": "Basic Settings",
"User ID": "User ID",
"Messaging API": "Messaging API",
wayToGetLineChannelToken: "First access the {0}, create a provider and channel (Messaging API), then you can get the channel access token and user id from the above mentioned menu items.",
"Icon URL": "Icon URL",
aboutIconURL: "You can provide a link to a picture in \"Icon URL\" to override the default profile picture. Will not be used if Icon Emoji is set.",
aboutMattermostChannelName: "You can override the default channel that webhook posts to by entering the channel name into \"Channel Name\" field. This needs to be enabled in Mattermost webhook settings. Ex: #other-channel",
"matrix": "Matrix",
// End notification form // End notification form
}; };

Loading…
Cancel
Save