diff options
author | Chocobozzz <me@florianbigard.com> | 2020-02-17 10:27:00 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-02-17 10:27:00 +0100 |
commit | 4c1c17093461b58d3ee3f23f239e340d8dac1149 (patch) | |
tree | 236b724f1415a812a4274fd63b519124cba2e42f /server/initializers | |
parent | 45f1bd72a08998c60a9dd68ff069cea9de39161c (diff) | |
download | PeerTube-4c1c17093461b58d3ee3f23f239e340d8dac1149.tar.gz PeerTube-4c1c17093461b58d3ee3f23f239e340d8dac1149.tar.zst PeerTube-4c1c17093461b58d3ee3f23f239e340d8dac1149.zip |
Refactor email enabled function
Diffstat (limited to 'server/initializers')
-rw-r--r-- | server/initializers/checker-after-init.ts | 5 | ||||
-rw-r--r-- | server/initializers/config.ts | 7 |
2 files changed, 8 insertions, 4 deletions
diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts index 978023129..e01609eef 100644 --- a/server/initializers/checker-after-init.ts +++ b/server/initializers/checker-after-init.ts | |||
@@ -4,13 +4,12 @@ import { UserModel } from '../models/account/user' | |||
4 | import { ApplicationModel } from '../models/application/application' | 4 | import { ApplicationModel } from '../models/application/application' |
5 | import { OAuthClientModel } from '../models/oauth/oauth-client' | 5 | import { OAuthClientModel } from '../models/oauth/oauth-client' |
6 | import { URL } from 'url' | 6 | import { URL } from 'url' |
7 | import { CONFIG } from './config' | 7 | import { CONFIG, isEmailEnabled } from './config' |
8 | import { logger } from '../helpers/logger' | 8 | import { logger } from '../helpers/logger' |
9 | import { getServerActor } from '../helpers/utils' | 9 | import { getServerActor } from '../helpers/utils' |
10 | import { RecentlyAddedStrategy } from '../../shared/models/redundancy' | 10 | import { RecentlyAddedStrategy } from '../../shared/models/redundancy' |
11 | import { isArray } from '../helpers/custom-validators/misc' | 11 | import { isArray } from '../helpers/custom-validators/misc' |
12 | import { uniq } from 'lodash' | 12 | import { uniq } from 'lodash' |
13 | import { Emailer } from '../lib/emailer' | ||
14 | import { WEBSERVER } from './constants' | 13 | import { WEBSERVER } from './constants' |
15 | 14 | ||
16 | async function checkActivityPubUrls () { | 15 | async function checkActivityPubUrls () { |
@@ -41,7 +40,7 @@ function checkConfig () { | |||
41 | } | 40 | } |
42 | 41 | ||
43 | // Email verification | 42 | // Email verification |
44 | if (!Emailer.isEnabled()) { | 43 | if (!isEmailEnabled()) { |
45 | if (CONFIG.SIGNUP.ENABLED && CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION) { | 44 | if (CONFIG.SIGNUP.ENABLED && CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION) { |
46 | return 'Emailer is disabled but you require signup email verification.' | 45 | return 'Emailer is disabled but you require signup email verification.' |
47 | } | 46 | } |
diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 75372fa4e..950ca61bd 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts | |||
@@ -284,11 +284,16 @@ function registerConfigChangedHandler (fun: Function) { | |||
284 | configChangedHandlers.push(fun) | 284 | configChangedHandlers.push(fun) |
285 | } | 285 | } |
286 | 286 | ||
287 | function isEmailEnabled () { | ||
288 | return !!CONFIG.SMTP.HOSTNAME && !!CONFIG.SMTP.PORT | ||
289 | } | ||
290 | |||
287 | // --------------------------------------------------------------------------- | 291 | // --------------------------------------------------------------------------- |
288 | 292 | ||
289 | export { | 293 | export { |
290 | CONFIG, | 294 | CONFIG, |
291 | registerConfigChangedHandler | 295 | registerConfigChangedHandler, |
296 | isEmailEnabled | ||
292 | } | 297 | } |
293 | 298 | ||
294 | // --------------------------------------------------------------------------- | 299 | // --------------------------------------------------------------------------- |