aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-02-17 10:27:00 +0100
committerChocobozzz <me@florianbigard.com>2020-02-17 10:27:00 +0100
commit4c1c17093461b58d3ee3f23f239e340d8dac1149 (patch)
tree236b724f1415a812a4274fd63b519124cba2e42f /server/middlewares
parent45f1bd72a08998c60a9dd68ff069cea9de39161c (diff)
downloadPeerTube-4c1c17093461b58d3ee3f23f239e340d8dac1149.tar.gz
PeerTube-4c1c17093461b58d3ee3f23f239e340d8dac1149.tar.zst
PeerTube-4c1c17093461b58d3ee3f23f239e340d8dac1149.zip
Refactor email enabled function
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/config.ts4
-rw-r--r--server/middlewares/validators/server.ts5
2 files changed, 4 insertions, 5 deletions
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'
3import { isUserNSFWPolicyValid, isUserVideoQuotaDailyValid, isUserVideoQuotaValid } from '../../helpers/custom-validators/users' 3import { isUserNSFWPolicyValid, isUserVideoQuotaDailyValid, isUserVideoQuotaValid } from '../../helpers/custom-validators/users'
4import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
5import { CustomConfig } from '../../../shared/models/server/custom-config.model' 5import { CustomConfig } from '../../../shared/models/server/custom-config.model'
6import { Emailer } from '../../lib/emailer'
7import { areValidationErrors } from './utils' 6import { areValidationErrors } from './utils'
8import { isThemeNameValid } from '../../helpers/custom-validators/plugins' 7import { isThemeNameValid } from '../../helpers/custom-validators/plugins'
9import { isThemeRegistered } from '../../lib/plugins/theme-utils' 8import { isThemeRegistered } from '../../lib/plugins/theme-utils'
9import { isEmailEnabled } from '@server/initializers/config'
10 10
11const customConfigUpdateValidator = [ 11const customConfigUpdateValidator = [
12 body('instance.name').exists().withMessage('Should have a valid instance name'), 12 body('instance.name').exists().withMessage('Should have a valid instance name'),
@@ -73,7 +73,7 @@ export {
73} 73}
74 74
75function checkInvalidConfigIfEmailDisabled (customConfig: CustomConfig, res: express.Response) { 75function checkInvalidConfigIfEmailDisabled (customConfig: CustomConfig, res: express.Response) {
76 if (Emailer.isEnabled()) return true 76 if (isEmailEnabled()) return true
77 77
78 if (customConfig.signup.requiresEmailVerification === true) { 78 if (customConfig.signup.requiresEmailVerification === true) {
79 res.status(400) 79 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
5import { ServerModel } from '../../models/server/server' 5import { ServerModel } from '../../models/server/server'
6import { body } from 'express-validator' 6import { body } from 'express-validator'
7import { isUserDisplayNameValid } from '../../helpers/custom-validators/users' 7import { isUserDisplayNameValid } from '../../helpers/custom-validators/users'
8import { Emailer } from '../../lib/emailer'
9import { Redis } from '../../lib/redis' 8import { Redis } from '../../lib/redis'
10import { CONFIG } from '../../initializers/config' 9import { CONFIG, isEmailEnabled } from '../../initializers/config'
11 10
12const serverGetValidator = [ 11const serverGetValidator = [
13 body('host').custom(isHostValid).withMessage('Should have a valid host'), 12 body('host').custom(isHostValid).withMessage('Should have a valid host'),
@@ -50,7 +49,7 @@ const contactAdministratorValidator = [
50 .end() 49 .end()
51 } 50 }
52 51
53 if (Emailer.isEnabled() === false) { 52 if (isEmailEnabled() === false) {
54 return res 53 return res
55 .status(409) 54 .status(409)
56 .send({ error: 'Emailer is not enabled on this instance.' }) 55 .send({ error: 'Emailer is not enabled on this instance.' })