aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/accounts.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-03-19 09:26:50 +0100
committerChocobozzz <me@florianbigard.com>2019-03-19 09:26:50 +0100
commit0f6acda11681de90d38dd18669863c6e270851ee (patch)
treeb3b28e00d539645f5a810202dc8afada289e7b2e /server/helpers/custom-validators/accounts.ts
parent9a18a6252071cf21b18f82a24bb63078abb75bc1 (diff)
downloadPeerTube-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.ts21
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'
5import { AccountModel } from '../../models/account/account' 5import { AccountModel } from '../../models/account/account'
6import { isUserDescriptionValid, isUserUsernameValid } from './users' 6import { isUserDescriptionValid, isUserUsernameValid } from './users'
7import { exists } from './misc' 7import { exists } from './misc'
8import { CONFIG } from '../../initializers'
9 8
10function isAccountNameValid (value: string) { 9function 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
22function isAccountIdExist (id: number | string, res: Response, sendNotFound = true) { 21function 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
34function isLocalAccountNameExist (name: string, res: Response, sendNotFound = true) { 33function 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
40function isAccountNameWithHostExist (nameWithDomain: string, res: Response, sendNotFound = true) { 39function 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
44async function isAccountExist (p: Bluebird<AccountModel>, res: Response, sendNotFound: boolean) { 43async 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
64export { 63export {
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}