diff --git a/db/patch-monitor-expiry-notification.sql b/db/patch-monitor-expiry-notification.sql new file mode 100644 index 000000000..7a330014a --- /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 26277e8db..156c295bc 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 10efc1a40..aef213c8e 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 dfff97e30..dc97d742d 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 42454e522..3d336ca62 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -139,6 +139,15 @@

{{ $t("Advanced") }}

+
+ + +
+
+
+