diff options
Diffstat (limited to 'server/helpers/custom-validators/accounts.ts')
-rw-r--r-- | server/helpers/custom-validators/accounts.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/server/helpers/custom-validators/accounts.ts b/server/helpers/custom-validators/accounts.ts index a46ffc162..cc8641d6b 100644 --- a/server/helpers/custom-validators/accounts.ts +++ b/server/helpers/custom-validators/accounts.ts | |||
@@ -31,6 +31,16 @@ function isLocalAccountNameExist (name: string, res: Response) { | |||
31 | return isAccountExist(promise, res) | 31 | return isAccountExist(promise, res) |
32 | } | 32 | } |
33 | 33 | ||
34 | function isAccountNameWithHostExist (nameWithDomain: string, res: Response) { | ||
35 | const [ accountName, host ] = nameWithDomain.split('@') | ||
36 | |||
37 | let promise: Bluebird<AccountModel> | ||
38 | if (!host) promise = AccountModel.loadLocalByName(accountName) | ||
39 | else promise = AccountModel.loadLocalByNameAndHost(accountName, host) | ||
40 | |||
41 | return isAccountExist(promise, res) | ||
42 | } | ||
43 | |||
34 | async function isAccountExist (p: Bluebird<AccountModel>, res: Response) { | 44 | async function isAccountExist (p: Bluebird<AccountModel>, res: Response) { |
35 | const account = await p | 45 | const account = await p |
36 | 46 | ||
@@ -53,5 +63,6 @@ export { | |||
53 | isAccountIdExist, | 63 | isAccountIdExist, |
54 | isLocalAccountNameExist, | 64 | isLocalAccountNameExist, |
55 | isAccountDescriptionValid, | 65 | isAccountDescriptionValid, |
66 | isAccountNameWithHostExist, | ||
56 | isAccountNameValid | 67 | isAccountNameValid |
57 | } | 68 | } |