aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/accounts.ts
diff options
context:
space:
mode:
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}