Chore: Combine if statements

pull/4700/head
Nelson Chan 3 weeks ago
parent 2027f4949f
commit 83a5b61211
No known key found for this signature in database

@ -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);
}
}
}

Loading…
Cancel
Save