From 82fb7b281622dfffdc0c549141b9ed8b40839004 Mon Sep 17 00:00:00 2001 From: Francesco M Date: Wed, 12 Jun 2024 08:46:48 +0200 Subject: [PATCH] improved zoho-cliq message format: - show PORT (cloned switchcase from discord,squadcast,servenio) - show monitorName in the first row to get on point also from messagge preview notification - avoid duplication of monitorName and monitorName in the message content --- server/notification-providers/zoho-cliq.js | 33 +++++++++++----------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/server/notification-providers/zoho-cliq.js b/server/notification-providers/zoho-cliq.js index 10381c81f..d67d7722a 100644 --- a/server/notification-providers/zoho-cliq.js +++ b/server/notification-providers/zoho-cliq.js @@ -13,9 +13,9 @@ class ZohoCliq extends NotificationProvider { */ _statusMessageFactory = (status, monitorName) => { if (status === DOWN) { - return `🔴 Application [${monitorName}] went down\n`; + return `🔴 [${monitorName}] went down\n`; } else if (status === UP) { - return `✅ Application [${monitorName}] is back online\n`; + return `✅ [${monitorName}] is back online\n`; } return "Notification\n"; }; @@ -46,16 +46,11 @@ class ZohoCliq extends NotificationProvider { monitorUrl, }) => { const payload = []; - payload.push("### Uptime Kuma\n"); payload.push(this._statusMessageFactory(status, monitorName)); payload.push(`*Description:* ${monitorMessage}`); - if (monitorName) { - payload.push(`*Monitor:* ${monitorName}`); - } - if (monitorUrl && monitorUrl !== "https://") { - payload.push(`*URL:* [${monitorUrl}](${monitorUrl})`); + payload.push(`*URL:* ${monitorUrl}`); } return payload; @@ -87,24 +82,30 @@ class ZohoCliq extends NotificationProvider { return okMsg; } - let url; + let address; + switch (monitorJSON["type"]) { - case "http": - case "keywork": - url = monitorJSON["url"]; + case "ping": + address = monitorJSON["hostname"]; break; - case "docker": - url = monitorJSON["docker_host"]; + case "port": + case "dns": + case "gamedig": + case "steam": + address = monitorJSON["hostname"]; + if (monitorJSON["port"]) { + address += ":" + monitorJSON["port"]; + } break; default: - url = monitorJSON["hostname"]; + address = monitorJSON["url"]; break; } const payload = this._notificationPayloadFactory({ monitorMessage: heartbeatJSON.msg, monitorName: monitorJSON.name, - monitorUrl: url, + monitorUrl: address, status: heartbeatJSON.status });