From 1488b1f17b28eebbfdf167a7d7e03de9075d97a9 Mon Sep 17 00:00:00 2001 From: Brodie Davis Date: Thu, 20 Jun 2024 11:54:20 -0400 Subject: [PATCH 1/7] prevent invalid url strings in monitorJSON --- server/model/monitor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index b3ed31d6c..2c0d6ded7 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -107,7 +107,7 @@ class Monitor extends BeanModel { pathName, parent: this.parent, childrenIDs: await Monitor.getAllChildrenIDs(this.id), - url: this.url, + url: this.getUrl(), method: this.method, hostname: this.hostname, port: this.port, From 94f75b2fbc3ef9226565d02cac24cb26f88d2d70 Mon Sep 17 00:00:00 2001 From: Brodie Davis Date: Thu, 20 Jun 2024 12:05:15 -0400 Subject: [PATCH 2/7] invalidate url field for irrelevant monitor types --- server/model/monitor.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/model/monitor.js b/server/model/monitor.js index 2c0d6ded7..510d5b760 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -1493,6 +1493,12 @@ class Monitor extends BeanModel { if (this.interval < MIN_INTERVAL_SECOND) { throw new Error(`Interval cannot be less than ${MIN_INTERVAL_SECOND} seconds`); } + + // Ensure URL is set to null for monitor types that don't use it, + // or the URL may be mistakenly used later (e.g., in notifications) + if (![ "http", "keyword", "json-query", "real-browser" ].includes(this.type)) { + this.url = null; + } } /** From 2c8cefc78463c8ec1d2e5a463850584cb4c81d89 Mon Sep 17 00:00:00 2001 From: Brodie Davis Date: Thu, 20 Jun 2024 12:10:49 -0400 Subject: [PATCH 3/7] use string url in json, not url object --- server/model/monitor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 510d5b760..253b50a11 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -107,7 +107,7 @@ class Monitor extends BeanModel { pathName, parent: this.parent, childrenIDs: await Monitor.getAllChildrenIDs(this.id), - url: this.getUrl(), + url: this.getUrl()?.href, method: this.method, hostname: this.hostname, port: this.port, From 0325c14d422f112c7e0443ce8d306ee8cc465008 Mon Sep 17 00:00:00 2001 From: Brodie Davis Date: Sun, 23 Jun 2024 21:16:27 -0400 Subject: [PATCH 4/7] remove unneeded validation --- server/model/monitor.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 253b50a11..94368b265 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -1493,12 +1493,6 @@ class Monitor extends BeanModel { if (this.interval < MIN_INTERVAL_SECOND) { throw new Error(`Interval cannot be less than ${MIN_INTERVAL_SECOND} seconds`); } - - // Ensure URL is set to null for monitor types that don't use it, - // or the URL may be mistakenly used later (e.g., in notifications) - if (![ "http", "keyword", "json-query", "real-browser" ].includes(this.type)) { - this.url = null; - } } /** From a19f417896c8184e44376ca08ad69976b5bf9a08 Mon Sep 17 00:00:00 2001 From: Brodie Davis Date: Sun, 23 Jun 2024 21:18:42 -0400 Subject: [PATCH 5/7] utilize extractAdress helper --- server/notification-providers/slack.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/notification-providers/slack.js b/server/notification-providers/slack.js index 439f5e905..acf7427ee 100644 --- a/server/notification-providers/slack.js +++ b/server/notification-providers/slack.js @@ -48,7 +48,7 @@ class Slack extends NotificationProvider { } - if (monitorJSON.url) { + if (this.extractAdress(monitorJSON)) { actions.push({ "type": "button", "text": { From 4b3ad53512a0d150f228c57dfee02009de53bbdc Mon Sep 17 00:00:00 2001 From: Brodie Davis Date: Thu, 27 Jun 2024 14:03:34 -0400 Subject: [PATCH 6/7] revert using url getter in monitor json --- server/model/monitor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 94368b265..b3ed31d6c 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -107,7 +107,7 @@ class Monitor extends BeanModel { pathName, parent: this.parent, childrenIDs: await Monitor.getAllChildrenIDs(this.id), - url: this.getUrl()?.href, + url: this.url, method: this.method, hostname: this.hostname, port: this.port, From 6eaf6b409c1e725dbb364feb4c286cec3a4d690f Mon Sep 17 00:00:00 2001 From: Brodie Davis Date: Thu, 27 Jun 2024 14:04:03 -0400 Subject: [PATCH 7/7] fix not utilizing fetched address --- server/notification-providers/slack.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/notification-providers/slack.js b/server/notification-providers/slack.js index acf7427ee..702256429 100644 --- a/server/notification-providers/slack.js +++ b/server/notification-providers/slack.js @@ -48,7 +48,8 @@ class Slack extends NotificationProvider { } - if (this.extractAdress(monitorJSON)) { + const address = this.extractAdress(monitorJSON); + if (address) { actions.push({ "type": "button", "text": { @@ -56,7 +57,7 @@ class Slack extends NotificationProvider { "text": "Visit site", }, "value": "Site", - "url": monitorJSON.url, + "url": address, }); }