From 83a5b61211cffbd20baa107b3f9b8f814d26e852 Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Mon, 22 Apr 2024 02:07:37 +0800 Subject: [PATCH] Chore: Combine if statements --- server/model/monitor.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 55830d8f..c3bcdef0 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -541,19 +541,17 @@ class Monitor extends BeanModel { // fallback for if kelog event is not emitted, but we may still have tlsInfo, // e.g. if the connection is made through a proxy - if (this.getUrl()?.protocol === "https:") { - if (tlsInfo.valid === undefined) { - const tlsSocket = res.request.res.socket; - - if (tlsSocket) { - tlsInfo.valid = tlsSocket.authorized || false; - tlsInfo = checkCertificate(tlsSocket); - await this.updateTlsInfo(tlsInfo); - - if (!this.getIgnoreTls() && this.isEnabledExpiryNotification()) { - log.debug("monitor", `[${this.name}] call checkCertExpiryNotifications`); - await this.checkCertExpiryNotifications(tlsInfo); - } + if (this.getUrl()?.protocol === "https:" && tlsInfo.valid === undefined) { + const tlsSocket = res.request.res.socket; + + if (tlsSocket) { + tlsInfo.valid = tlsSocket.authorized || false; + tlsInfo = checkCertificate(tlsSocket); + await this.updateTlsInfo(tlsInfo); + + if (!this.getIgnoreTls() && this.isEnabledExpiryNotification()) { + log.debug("monitor", `[${this.name}] call checkCertExpiryNotifications`); + await this.checkCertExpiryNotifications(tlsInfo); } } }