Skip to content

Commit f27811c

Browse files
ntfy.sh separate down priority (#5893)
Co-authored-by: Frank Elsinga <frank@elsinga.de>
1 parent c46772d commit f27811c

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

server/notification-providers/ntfy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ class Ntfy extends NotificationProvider {
4141
if (heartbeatJSON.status === DOWN) {
4242
tags = [ "red_circle" ];
4343
status = "Down";
44-
// if priority is not 5, increase priority for down alerts
45-
priority = priority === 5 ? priority : priority + 1;
44+
// defaults to max(priority + 1, 5)
45+
priority = notification.ntfyPriorityDown || (priority === 5 ? priority : priority + 1);
4646
} else if (heartbeatJSON["status"] === UP) {
4747
tags = [ "green_circle" ];
4848
status = "Up";

src/components/notifications/Ntfy.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,20 @@
1313
<div class="mb-3">
1414
<label for="ntfy-priority" class="form-label">{{ $t("Priority") }}</label>
1515
<input id="ntfy-priority" v-model="$parent.notification.ntfyPriority" type="number" class="form-control" required min="1" max="5" step="1">
16+
<label for="ntfy-priority-down" class="form-label">{{ $t("ntfyPriorityDown") }}</label>
17+
<input id="ntfy-priority-down" v-model="$parent.notification.ntfyPriorityDown" type="number" class="form-control" required min="1" max="5" step="1">
1618
<div class="form-text">
17-
<p v-if="$parent.notification.ntfyPriority >= 5">
19+
<p v-if="$parent.notification.ntfyPriority == $parent.notification.ntfyPriorityDown && $parent.notification.ntfyPriority >= 5">
1820
{{ $t("ntfyPriorityHelptextAllEvents") }}
1921
</p>
22+
<i18n-t v-else-if="$parent.notification.ntfyPriority > $parent.notification.ntfyPriorityDown" tag="p" keypath="ntfyPriorityHelptextPriorityHigherThanDown">
23+
<code>DOWN</code>
24+
<code>{{ $parent.notification.ntfyPriority }}</code>
25+
<code>{{ $parent.notification.ntfyPriorityDown }}</code>
26+
</i18n-t>
2027
<i18n-t v-else tag="p" keypath="ntfyPriorityHelptextAllExceptDown">
2128
<code>DOWN</code>
22-
<code>{{ $parent.notification.ntfyPriority + 1 }}</code>
29+
<code>{{ $parent.notification.ntfyPriorityDown }}</code>
2330
</i18n-t>
2431
</div>
2532
</div>
@@ -69,6 +76,11 @@ export default {
6976
this.$parent.notification.ntfyPriority = 5;
7077
}
7178
79+
// Setting down priority if it's undefined
80+
if (typeof this.$parent.notification.ntfyPriorityDown === "undefined") {
81+
this.$parent.notification.ntfyPriorityDown = 5;
82+
}
83+
7284
// Handling notifications that added before 1.22.0
7385
if (typeof this.$parent.notification.ntfyAuthenticationMethod === "undefined") {
7486
if (!this.$parent.notification.ntfyusername) {

src/lang/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,8 @@
841841
"ntfyAuthenticationMethod": "Authentication Method",
842842
"ntfyPriorityHelptextAllEvents": "All events are sent with the maximum priority",
843843
"ntfyPriorityHelptextAllExceptDown": "All events are sent with this priority, except {0}-events, which have a priority of {1}",
844+
"ntfyPriorityHelptextPriorityHigherThanDown": "Regular priority should be higher than {0} priority. Priority {1} is higher than {0} priority {2}",
845+
"ntfyPriorityDown": "Priority for DOWN-events",
844846
"ntfyUsernameAndPassword": "Username and Password",
845847
"twilioAccountSID": "Account SID",
846848
"twilioApiKey": "Api Key (optional)",

0 commit comments

Comments
 (0)