mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-04 00:29:51 -06:00
fix: added email connection validation
This commit is contained in:
@@ -278,7 +278,7 @@ const settingsValidation = joi.object({
|
||||
systemEmailAddress: joi.string().allow(""),
|
||||
systemEmailPassword: joi.string().allow(""),
|
||||
systemEmailUser: joi.string().allow(""),
|
||||
systemEmailConnectionHost: joi.string().allow("").optional(),
|
||||
systemEmailConnectionHost: joi.string().allow(""),
|
||||
});
|
||||
|
||||
const dayjsValidator = (value, helpers) => {
|
||||
@@ -308,7 +308,7 @@ const advancedSettingsValidation = joi.object({
|
||||
systemEmailPort: joi.number().allow(null, ""),
|
||||
systemEmailAddress: joi.string().allow(""),
|
||||
systemEmailPassword: joi.string().allow(""),
|
||||
systemEmailConnectionHost: joi.string().allow("").optional(),
|
||||
systemEmailConnectionHost: joi.string().allow(""),
|
||||
jwtTTLNum: joi.number().messages({
|
||||
"number.base": "JWT TTL is required.",
|
||||
}),
|
||||
|
||||
@@ -30,6 +30,7 @@ const AppSettingsSchema = mongoose.Schema(
|
||||
},
|
||||
systemEmailConnectionHost: {
|
||||
type: String,
|
||||
default: "localhost",
|
||||
},
|
||||
singleton: {
|
||||
type: Boolean,
|
||||
|
||||
@@ -11,6 +11,7 @@ const SERVICE_NAME = "EmailService";
|
||||
*/
|
||||
class EmailService {
|
||||
static SERVICE_NAME = SERVICE_NAME;
|
||||
|
||||
/**
|
||||
* Constructs an instance of the EmailService, initializing template loaders and the email transporter.
|
||||
* @param {Object} settingsService - The settings service to get email configuration.
|
||||
@@ -96,7 +97,7 @@ class EmailService {
|
||||
systemEmailUser,
|
||||
systemEmailAddress,
|
||||
systemEmailPassword,
|
||||
systemEmailConnectionHost
|
||||
systemEmailConnectionHost,
|
||||
} = await this.settingsService.getDBSettings();
|
||||
|
||||
const baseEmailConfig = {
|
||||
@@ -112,13 +113,15 @@ class EmailService {
|
||||
|
||||
const isSmtps = Number(systemEmailPort) === 465;
|
||||
|
||||
const emailConfig = !isSmtps ? {
|
||||
...baseEmailConfig,
|
||||
name: systemEmailConnectionHost || "127.0.0.1",
|
||||
secure: false,
|
||||
pool: true,
|
||||
tls: { rejectUnauthorized: false },
|
||||
} : baseEmailConfig;
|
||||
const emailConfig = !isSmtps
|
||||
? {
|
||||
...baseEmailConfig,
|
||||
name: systemEmailConnectionHost || "localhost",
|
||||
secure: false,
|
||||
pool: true,
|
||||
tls: { rejectUnauthorized: false },
|
||||
}
|
||||
: baseEmailConfig;
|
||||
|
||||
if (!isSmtps) {
|
||||
delete emailConfig.auth;
|
||||
@@ -164,4 +167,5 @@ class EmailService {
|
||||
return info?.messageId;
|
||||
};
|
||||
}
|
||||
|
||||
export default EmailService;
|
||||
|
||||
Reference in New Issue
Block a user