diff options
Diffstat (limited to 'server/models/account')
-rw-r--r-- | server/models/account/account.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/server/models/account/account.ts b/server/models/account/account.ts index 84ef0b30d..747b51afb 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts | |||
@@ -24,6 +24,8 @@ import { getSort, throwIfNotValid } from '../utils' | |||
24 | import { VideoChannelModel } from '../video/video-channel' | 24 | import { VideoChannelModel } from '../video/video-channel' |
25 | import { VideoCommentModel } from '../video/video-comment' | 25 | import { VideoCommentModel } from '../video/video-comment' |
26 | import { UserModel } from './user' | 26 | import { UserModel } from './user' |
27 | import * as Bluebird from '../../helpers/custom-validators/accounts' | ||
28 | import { CONFIG } from '../../initializers' | ||
27 | 29 | ||
28 | @DefaultScope({ | 30 | @DefaultScope({ |
29 | include: [ | 31 | include: [ |
@@ -153,6 +155,14 @@ export class AccountModel extends Model<AccountModel> { | |||
153 | return AccountModel.findOne(query) | 155 | return AccountModel.findOne(query) |
154 | } | 156 | } |
155 | 157 | ||
158 | static loadByNameWithHost (nameWithHost: string) { | ||
159 | const [ accountName, host ] = nameWithHost.split('@') | ||
160 | |||
161 | if (!host || host === CONFIG.WEBSERVER.HOST) return AccountModel.loadLocalByName(accountName) | ||
162 | |||
163 | return AccountModel.loadByNameAndHost(accountName, host) | ||
164 | } | ||
165 | |||
156 | static loadLocalByName (name: string) { | 166 | static loadLocalByName (name: string) { |
157 | const query = { | 167 | const query = { |
158 | where: { | 168 | where: { |