mirror of
https://github.com/louislam/uptime-kuma.git
synced 2026-03-03 00:37:01 +00:00
feat: allow templating in the Signal notificaiton provider (#6989)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
committed by
GitHub
parent
c90a7f30e1
commit
019b4b7503
@@ -11,8 +11,14 @@ class Signal extends NotificationProvider {
|
||||
const okMsg = "Sent Successfully.";
|
||||
|
||||
try {
|
||||
let message = msg;
|
||||
|
||||
if (notification.signalUseTemplate) {
|
||||
message = await this.renderTemplate(notification.signalTemplate, msg, monitorJSON, heartbeatJSON);
|
||||
}
|
||||
|
||||
let data = {
|
||||
message: msg,
|
||||
message,
|
||||
number: notification.signalNumber,
|
||||
recipients: notification.signalRecipients.replace(/\s/g, "").split(","),
|
||||
};
|
||||
|
||||
@@ -52,4 +52,48 @@
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<div class="form-check form-switch">
|
||||
<input v-model="$parent.notification.signalUseTemplate" class="form-check-input" type="checkbox" />
|
||||
<label class="form-check-label">{{ $t("signalUseTemplate") }}</label>
|
||||
</div>
|
||||
|
||||
<div class="form-text">
|
||||
{{ $t("signalUseTemplateDescription") }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template v-if="$parent.notification.signalUseTemplate">
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="signal-template">{{ $t("Message Template") }}</label>
|
||||
<TemplatedTextarea
|
||||
id="signal-template"
|
||||
v-model="$parent.notification.signalTemplate"
|
||||
:required="true"
|
||||
:placeholder="signalTemplatedTextareaPlaceholder"
|
||||
></TemplatedTextarea>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import TemplatedTextarea from "../TemplatedTextarea.vue";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
TemplatedTextarea,
|
||||
},
|
||||
computed: {
|
||||
signalTemplatedTextareaPlaceholder() {
|
||||
return this.$t("Example:", [
|
||||
`
|
||||
Signal Alert{% if monitorJSON %} - {{ monitorJSON['name'] }}{% endif %}
|
||||
|
||||
{{ msg }}
|
||||
`,
|
||||
]);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -863,6 +863,8 @@
|
||||
"Remove domain": "Remove domain '{0}'",
|
||||
"Icon Emoji": "Icon Emoji",
|
||||
"signalImportant": "IMPORTANT: You cannot mix groups and numbers in recipients!",
|
||||
"signalUseTemplate": "Use custom message template",
|
||||
"signalUseTemplateDescription": "If enabled, the message will be sent using a custom template. You can use Liquid templating to customize the notification format.",
|
||||
"aboutWebhooks": "More info about Webhooks on: {0}",
|
||||
"aboutJiraCloudId": "More info about Jira Cloud ID: {0}",
|
||||
"see Jira Cloud Docs": "see Jira Cloud Docs",
|
||||
|
||||
Reference in New Issue
Block a user