From 70311f7a5a64ed800fad0a7c94c6f781f16c0e85 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Tue, 5 Apr 2022 21:27:50 +0800 Subject: [PATCH] Add an option to enable/disable the domain name expiry notification #1364 --- db/patch-monitor-expiry-notification.sql | 7 +++++++ server/database.js | 1 + server/model/monitor.js | 7 ++++++- server/server.js | 1 + src/pages/EditMonitor.vue | 10 ++++++++++ 5 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 db/patch-monitor-expiry-notification.sql diff --git a/db/patch-monitor-expiry-notification.sql b/db/patch-monitor-expiry-notification.sql new file mode 100644 index 00000000..7a330014 --- /dev/null +++ b/db/patch-monitor-expiry-notification.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD expiry_notification BOOLEAN default 1; + +COMMIT; diff --git a/server/database.js b/server/database.js index 26277e8d..156c295b 100644 --- a/server/database.js +++ b/server/database.js @@ -55,6 +55,7 @@ class Database { "patch-monitor-basic-auth.sql": true, "patch-status-page.sql": true, "patch-proxy.sql": true, + "patch-monitor-expiry-notification.sql": true, } /** diff --git a/server/model/monitor.js b/server/model/monitor.js index 10efc1a4..aef213c8 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -74,6 +74,7 @@ class Monitor extends BeanModel { interval: this.interval, retryInterval: this.retryInterval, keyword: this.keyword, + expiryNotification: this.isEnabledExpiryNotification(), ignoreTls: this.getIgnoreTls(), upsideDown: this.isUpsideDown(), maxredirects: this.maxredirects, @@ -101,6 +102,10 @@ class Monitor extends BeanModel { return Buffer.from(user + ":" + pass).toString("base64"); } + isEnabledExpiryNotification() { + return Boolean(this.expiryNotification); + } + /** * Parse to boolean * @returns {boolean} @@ -240,7 +245,7 @@ class Monitor extends BeanModel { let tlsInfoObject = checkCertificate(res); tlsInfo = await this.updateTlsInfo(tlsInfoObject); - if (!this.getIgnoreTls()) { + if (!this.getIgnoreTls() && this.isEnabledExpiryNotification()) { debug(`[${this.name}] call sendCertNotification`); await this.sendCertNotification(tlsInfoObject); } diff --git a/server/server.js b/server/server.js index dfff97e3..dc97d742 100644 --- a/server/server.js +++ b/server/server.js @@ -646,6 +646,7 @@ exports.entryPage = "dashboard"; bean.port = monitor.port; bean.keyword = monitor.keyword; bean.ignoreTls = monitor.ignoreTls; + bean.expiryNotification = monitor.expiryNotification; bean.upsideDown = monitor.upsideDown; bean.maxredirects = monitor.maxredirects; bean.accepted_statuscodes_json = JSON.stringify(monitor.accepted_statuscodes); diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 42454e52..3d336ca6 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -139,6 +139,15 @@

{{ $t("Advanced") }}

+
+ + +
+
+
+