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:
Karthikeya chanda
2026-02-20 01:00:49 +05:30
committed by GitHub
parent c90a7f30e1
commit 019b4b7503
3 changed files with 53 additions and 1 deletions

View File

@@ -11,8 +11,14 @@ class Signal extends NotificationProvider {
const okMsg = "Sent Successfully."; const okMsg = "Sent Successfully.";
try { try {
let message = msg;
if (notification.signalUseTemplate) {
message = await this.renderTemplate(notification.signalTemplate, msg, monitorJSON, heartbeatJSON);
}
let data = { let data = {
message: msg, message,
number: notification.signalNumber, number: notification.signalNumber,
recipients: notification.signalRecipients.replace(/\s/g, "").split(","), recipients: notification.signalRecipients.replace(/\s/g, "").split(","),
}; };

View File

@@ -52,4 +52,48 @@
</p> </p>
</div> </div>
</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> </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>

View File

@@ -863,6 +863,8 @@
"Remove domain": "Remove domain '{0}'", "Remove domain": "Remove domain '{0}'",
"Icon Emoji": "Icon Emoji", "Icon Emoji": "Icon Emoji",
"signalImportant": "IMPORTANT: You cannot mix groups and numbers in recipients!", "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}", "aboutWebhooks": "More info about Webhooks on: {0}",
"aboutJiraCloudId": "More info about Jira Cloud ID: {0}", "aboutJiraCloudId": "More info about Jira Cloud ID: {0}",
"see Jira Cloud Docs": "see Jira Cloud Docs", "see Jira Cloud Docs": "see Jira Cloud Docs",