Make icon optional for ntfy notificaation provider. Add Icon header to ntfy request only, if icon is actually defined.

This commit is contained in:
Christian Meis 2022-10-11 11:15:33 +02:00
parent c03d911657
commit 1e8a16504b
2 changed files with 8 additions and 5 deletions

View File

@ -7,15 +7,18 @@ class Ntfy extends NotificationProvider {
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully.";
try {
await axios.post(`${notification.ntfyserverurl}`, {
var ntfyparams = {
"topic": notification.ntfytopic,
"message": msg,
"priority": notification.ntfyPriority || 4,
"title": "Uptime-Kuma",
"icon": notification.ntfyIcon || "",
});
};
if (notification.ntfyIcon) {
ntfyparams.icon = notification.ntfyIcon;
}
try {
await axios.post(`${notification.ntfyserverurl}`, ntfyparams);
return okMsg;
} catch (error) {

View File

@ -19,7 +19,7 @@
<div class="mb-3">
<label for="ntfy-icon" class="form-label">{{ $t("IconUrl") }}</label>
<input id="ntfy-icon" v-model="$parent.notification.ntfyIcon" type="text" class="form-control" required>
<input id="ntfy-icon" v-model="$parent.notification.ntfyIcon" type="text" class="form-control">
</div>
</template>