diff options
Diffstat (limited to 'server/helpers/utils.ts')
-rw-r--r-- | server/helpers/utils.ts | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index 6cabe117c..8b81a61e1 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts | |||
@@ -8,11 +8,13 @@ import { ResultList } from '../../shared' | |||
8 | import { VideoResolution } from '../../shared/models/videos/video-resolution.enum' | 8 | import { VideoResolution } from '../../shared/models/videos/video-resolution.enum' |
9 | 9 | ||
10 | function badRequest (req: express.Request, res: express.Response, next: express.NextFunction) { | 10 | function badRequest (req: express.Request, res: express.Response, next: express.NextFunction) { |
11 | res.type('json').status(400).end() | 11 | return res.type('json').status(400).end() |
12 | } | 12 | } |
13 | 13 | ||
14 | function generateRandomString (size: number) { | 14 | async function generateRandomString (size: number) { |
15 | return pseudoRandomBytesPromise(size).then(raw => raw.toString('hex')) | 15 | const raw = await pseudoRandomBytesPromise(size) |
16 | |||
17 | return raw.toString('hex') | ||
16 | } | 18 | } |
17 | 19 | ||
18 | interface FormattableToJSON { | 20 | interface FormattableToJSON { |
@@ -34,19 +36,19 @@ function getFormattedObjects<U, T extends FormattableToJSON> (objects: T[], obje | |||
34 | return res | 36 | return res |
35 | } | 37 | } |
36 | 38 | ||
37 | function isSignupAllowed () { | 39 | async function isSignupAllowed () { |
38 | if (CONFIG.SIGNUP.ENABLED === false) { | 40 | if (CONFIG.SIGNUP.ENABLED === false) { |
39 | return Promise.resolve(false) | 41 | return false |
40 | } | 42 | } |
41 | 43 | ||
42 | // No limit and signup is enabled | 44 | // No limit and signup is enabled |
43 | if (CONFIG.SIGNUP.LIMIT === -1) { | 45 | if (CONFIG.SIGNUP.LIMIT === -1) { |
44 | return Promise.resolve(true) | 46 | return true |
45 | } | 47 | } |
46 | 48 | ||
47 | return db.User.countTotal().then(totalUsers => { | 49 | const totalUsers = await db.User.countTotal() |
48 | return totalUsers < CONFIG.SIGNUP.LIMIT | 50 | |
49 | }) | 51 | return totalUsers < CONFIG.SIGNUP.LIMIT |
50 | } | 52 | } |
51 | 53 | ||
52 | function computeResolutionsToTranscode (videoFileHeight: number) { | 54 | function computeResolutionsToTranscode (videoFileHeight: number) { |