diff options
author | Chocobozzz <me@florianbigard.com> | 2019-03-19 09:26:50 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-03-19 09:26:50 +0100 |
commit | 0f6acda11681de90d38dd18669863c6e270851ee (patch) | |
tree | b3b28e00d539645f5a810202dc8afada289e7b2e /server/helpers/custom-validators/accounts.ts | |
parent | 9a18a6252071cf21b18f82a24bb63078abb75bc1 (diff) | |
download | PeerTube-0f6acda11681de90d38dd18669863c6e270851ee.tar.gz PeerTube-0f6acda11681de90d38dd18669863c6e270851ee.tar.zst PeerTube-0f6acda11681de90d38dd18669863c6e270851ee.zip |
Does exist
Diffstat (limited to 'server/helpers/custom-validators/accounts.ts')
-rw-r--r-- | server/helpers/custom-validators/accounts.ts | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/server/helpers/custom-validators/accounts.ts b/server/helpers/custom-validators/accounts.ts index aad04fe93..146c7708e 100644 --- a/server/helpers/custom-validators/accounts.ts +++ b/server/helpers/custom-validators/accounts.ts | |||
@@ -5,7 +5,6 @@ import * as validator from 'validator' | |||
5 | import { AccountModel } from '../../models/account/account' | 5 | import { AccountModel } from '../../models/account/account' |
6 | import { isUserDescriptionValid, isUserUsernameValid } from './users' | 6 | import { isUserDescriptionValid, isUserUsernameValid } from './users' |
7 | import { exists } from './misc' | 7 | import { exists } from './misc' |
8 | import { CONFIG } from '../../initializers' | ||
9 | 8 | ||
10 | function isAccountNameValid (value: string) { | 9 | function isAccountNameValid (value: string) { |
11 | return isUserUsernameValid(value) | 10 | return isUserUsernameValid(value) |
@@ -19,7 +18,7 @@ function isAccountDescriptionValid (value: string) { | |||
19 | return isUserDescriptionValid(value) | 18 | return isUserDescriptionValid(value) |
20 | } | 19 | } |
21 | 20 | ||
22 | function isAccountIdExist (id: number | string, res: Response, sendNotFound = true) { | 21 | function doesAccountIdExist (id: number | string, res: Response, sendNotFound = true) { |
23 | let promise: Bluebird<AccountModel> | 22 | let promise: Bluebird<AccountModel> |
24 | 23 | ||
25 | if (validator.isInt('' + id)) { | 24 | if (validator.isInt('' + id)) { |
@@ -28,20 +27,20 @@ function isAccountIdExist (id: number | string, res: Response, sendNotFound = tr | |||
28 | promise = AccountModel.loadByUUID('' + id) | 27 | promise = AccountModel.loadByUUID('' + id) |
29 | } | 28 | } |
30 | 29 | ||
31 | return isAccountExist(promise, res, sendNotFound) | 30 | return doesAccountExist(promise, res, sendNotFound) |
32 | } | 31 | } |
33 | 32 | ||
34 | function isLocalAccountNameExist (name: string, res: Response, sendNotFound = true) { | 33 | function doesLocalAccountNameExist (name: string, res: Response, sendNotFound = true) { |
35 | const promise = AccountModel.loadLocalByName(name) | 34 | const promise = AccountModel.loadLocalByName(name) |
36 | 35 | ||
37 | return isAccountExist(promise, res, sendNotFound) | 36 | return doesAccountExist(promise, res, sendNotFound) |
38 | } | 37 | } |
39 | 38 | ||
40 | function isAccountNameWithHostExist (nameWithDomain: string, res: Response, sendNotFound = true) { | 39 | function doesAccountNameWithHostExist (nameWithDomain: string, res: Response, sendNotFound = true) { |
41 | return isAccountExist(AccountModel.loadByNameWithHost(nameWithDomain), res, sendNotFound) | 40 | return doesAccountExist(AccountModel.loadByNameWithHost(nameWithDomain), res, sendNotFound) |
42 | } | 41 | } |
43 | 42 | ||
44 | async function isAccountExist (p: Bluebird<AccountModel>, res: Response, sendNotFound: boolean) { | 43 | async function doesAccountExist (p: Bluebird<AccountModel>, res: Response, sendNotFound: boolean) { |
45 | const account = await p | 44 | const account = await p |
46 | 45 | ||
47 | if (!account) { | 46 | if (!account) { |
@@ -63,9 +62,9 @@ async function isAccountExist (p: Bluebird<AccountModel>, res: Response, sendNot | |||
63 | 62 | ||
64 | export { | 63 | export { |
65 | isAccountIdValid, | 64 | isAccountIdValid, |
66 | isAccountIdExist, | 65 | doesAccountIdExist, |
67 | isLocalAccountNameExist, | 66 | doesLocalAccountNameExist, |
68 | isAccountDescriptionValid, | 67 | isAccountDescriptionValid, |
69 | isAccountNameWithHostExist, | 68 | doesAccountNameWithHostExist, |
70 | isAccountNameValid | 69 | isAccountNameValid |
71 | } | 70 | } |