mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-09-07 09:51:57 +00:00
add support for signal notifications
This commit is contained in:
parent
11a2adcb7c
commit
c6237277c0
@ -56,6 +56,22 @@ class Notification {
|
|||||||
} else if (notification.type === "discord") {
|
} else if (notification.type === "discord") {
|
||||||
return await Notification.discord(notification, msg)
|
return await Notification.discord(notification, msg)
|
||||||
|
|
||||||
|
} else if (notification.type === "signal") {
|
||||||
|
try {
|
||||||
|
let data = {
|
||||||
|
"message": msg,
|
||||||
|
"number": notification.signalNumber,
|
||||||
|
"recipients": notification.signalRecipients.replace(/\s/g, '').split(",")
|
||||||
|
};
|
||||||
|
let config = {};
|
||||||
|
|
||||||
|
let res = await axios.post(notification.signalURL, data, config)
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Notification type is not supported")
|
throw new Error("Notification type is not supported")
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
<option value="webhook">Webhook</option>
|
<option value="webhook">Webhook</option>
|
||||||
<option value="smtp">Email (SMTP)</option>
|
<option value="smtp">Email (SMTP)</option>
|
||||||
<option value="discord">Discord</option>
|
<option value="discord">Discord</option>
|
||||||
|
<option value="signal">Signal</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -44,9 +45,8 @@
|
|||||||
Support Direct Chat / Group / Channel's Chat ID
|
Support Direct Chat / Group / Channel's Chat ID
|
||||||
|
|
||||||
<p style="margin-top: 8px;">
|
<p style="margin-top: 8px;">
|
||||||
You can get your chat id by sending message to the bot and go to this url to view the chat_id:
|
You can ge <a href="https://github.com/bbernhard/signal-cli-rest-api" target="_blank">https://github.com/bbernhard/signal-cli-rest-api</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p style="margin-top: 8px;">
|
<p style="margin-top: 8px;">
|
||||||
|
|
||||||
<template v-if="notification.telegramBotToken">
|
<template v-if="notification.telegramBotToken">
|
||||||
@ -143,6 +143,41 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template v-if="notification.type === 'signal'">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="signal-url" class="form-label">Post URL</label>
|
||||||
|
<input type="url" pattern="https?://.+" class="form-control" id="signal-url" required v-model="notification.signalURL">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="signal-number" class="form-label">Number</label>
|
||||||
|
<input type="text" class="form-control" id="signal-number" required v-model="notification.signalNumber">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="signal-recipients" class="form-label">Recipients</label>
|
||||||
|
<input type="text" class="form-control" id="signal-recipients" required v-model="notification.signalRecipients">
|
||||||
|
|
||||||
|
<div class="form-text">
|
||||||
|
You need to have a signal client with REST API.
|
||||||
|
|
||||||
|
<p style="margin-top: 8px;">
|
||||||
|
You can check this url to view how to setup one:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p style="margin-top: 8px;">
|
||||||
|
<a href="https://github.com/bbernhard/signal-cli-rest-api" target="_blank">https://github.com/bbernhard/signal-cli-rest-api</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p style="margin-top: 8px;">
|
||||||
|
IMPORTANT: You cannot mix groups and numbers in recipients!
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-danger" @click="deleteConfirm" :disabled="processing" v-if="id">Delete</button>
|
<button type="button" class="btn btn-danger" @click="deleteConfirm" :disabled="processing" v-if="id">Delete</button>
|
||||||
@ -236,6 +271,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
test() {
|
test() {
|
||||||
|
console.log("test notification");
|
||||||
this.processing = true;
|
this.processing = true;
|
||||||
this.$root.getSocket().emit("testNotification", this.notification, (res) => {
|
this.$root.getSocket().emit("testNotification", this.notification, (res) => {
|
||||||
this.$root.toastRes(res)
|
this.$root.toastRes(res)
|
||||||
|
Loading…
Reference in New Issue
Block a user