mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-02-26 13:35:56 +00:00
delint
This commit is contained in:
parent
16edd5932e
commit
ab0ba80db7
1 changed files with 20 additions and 8 deletions
|
@ -1,22 +1,34 @@
|
|||
const { MonitorType } = require("./monitor-type");
|
||||
const { UP, log, evaluateJsonQuery } = require("../../src/util");
|
||||
const { UP } = require("../../src/util");
|
||||
const nodemailer = require("nodemailer");
|
||||
|
||||
class SMTPMonitorType extends MonitorType {
|
||||
name = "smtp";
|
||||
|
||||
/**
|
||||
* @param {*} smtpSecurity the user's SMTP security setting
|
||||
* @returns {boolean} True if this should test SMTPS
|
||||
*/
|
||||
isSMTPS(smtpSecurity) {
|
||||
return smtpSecurity === 'secure';
|
||||
return smtpSecurity === "secure";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} smtpSecurity the user's SMTP security setting
|
||||
* @returns {boolean} True if this should not attempt STARTTLS, even if it is available
|
||||
*/
|
||||
isIgnoreTLS(smtpSecurity) {
|
||||
return smtpSecurity === 'nostarttls';
|
||||
return smtpSecurity === "nostarttls";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} smtpSecurity the user's SMTP security setting
|
||||
* @returns {boolean} True if this should always test STARTTLS
|
||||
*/
|
||||
isRequireTLS(smtpSecurity) {
|
||||
return smtpSecurity === 'starttls';
|
||||
return smtpSecurity === "starttls";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
|
@ -27,13 +39,13 @@ class SMTPMonitorType extends MonitorType {
|
|||
secure: this.isSMTPS(monitor.smtpSecurity), // use SMTPS (not STARTTLS)
|
||||
ignoreTLS: this.isIgnoreTLS(monitor.smtpSecurity), // don't use STARTTLS even if it's available
|
||||
requireTLS: this.isRequireTLS(monitor.smtpSecurity), // use STARTTLS or fail
|
||||
}
|
||||
};
|
||||
let transporter = nodemailer.createTransport(options);
|
||||
try {
|
||||
await transporter.verify();
|
||||
|
||||
heartbeat.status = UP;
|
||||
heartbeat.msg = `SMTP connection verifies successfully`;
|
||||
heartbeat.msg = "SMTP connection verifies successfully";
|
||||
} catch (e) {
|
||||
throw new Error(`SMTP connection doesn't verify: ${e}`);
|
||||
} finally {
|
||||
|
@ -44,4 +56,4 @@ class SMTPMonitorType extends MonitorType {
|
|||
|
||||
module.exports = {
|
||||
SMTPMonitorType,
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue