From 4c1c17093461b58d3ee3f23f239e340d8dac1149 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 17 Feb 2020 10:27:00 +0100 Subject: Refactor email enabled function --- server/middlewares/validators/config.ts | 4 ++-- server/middlewares/validators/server.ts | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'server/middlewares') diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts index ceab646c0..dfa549e76 100644 --- a/server/middlewares/validators/config.ts +++ b/server/middlewares/validators/config.ts @@ -3,10 +3,10 @@ import { body } from 'express-validator' import { isUserNSFWPolicyValid, isUserVideoQuotaDailyValid, isUserVideoQuotaValid } from '../../helpers/custom-validators/users' import { logger } from '../../helpers/logger' import { CustomConfig } from '../../../shared/models/server/custom-config.model' -import { Emailer } from '../../lib/emailer' import { areValidationErrors } from './utils' import { isThemeNameValid } from '../../helpers/custom-validators/plugins' import { isThemeRegistered } from '../../lib/plugins/theme-utils' +import { isEmailEnabled } from '@server/initializers/config' const customConfigUpdateValidator = [ body('instance.name').exists().withMessage('Should have a valid instance name'), @@ -73,7 +73,7 @@ export { } function checkInvalidConfigIfEmailDisabled (customConfig: CustomConfig, res: express.Response) { - if (Emailer.isEnabled()) return true + if (isEmailEnabled()) return true if (customConfig.signup.requiresEmailVerification === true) { res.status(400) diff --git a/server/middlewares/validators/server.ts b/server/middlewares/validators/server.ts index f6812647b..6158c3363 100644 --- a/server/middlewares/validators/server.ts +++ b/server/middlewares/validators/server.ts @@ -5,9 +5,8 @@ import { isHostValid, isValidContactBody } from '../../helpers/custom-validators import { ServerModel } from '../../models/server/server' import { body } from 'express-validator' import { isUserDisplayNameValid } from '../../helpers/custom-validators/users' -import { Emailer } from '../../lib/emailer' import { Redis } from '../../lib/redis' -import { CONFIG } from '../../initializers/config' +import { CONFIG, isEmailEnabled } from '../../initializers/config' const serverGetValidator = [ body('host').custom(isHostValid).withMessage('Should have a valid host'), @@ -50,7 +49,7 @@ const contactAdministratorValidator = [ .end() } - if (Emailer.isEnabled() === false) { + if (isEmailEnabled() === false) { return res .status(409) .send({ error: 'Emailer is not enabled on this instance.' }) -- cgit v1.2.3