diff options
Diffstat (limited to 'server/models/account/user.ts')
-rw-r--r-- | server/models/account/user.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/server/models/account/user.ts b/server/models/account/user.ts index 89265774b..4b13e47a0 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts | |||
@@ -39,6 +39,7 @@ import { AccountModel } from './account' | |||
39 | import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type' | 39 | import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type' |
40 | import { values } from 'lodash' | 40 | import { values } from 'lodash' |
41 | import { NSFW_POLICY_TYPES } from '../../initializers' | 41 | import { NSFW_POLICY_TYPES } from '../../initializers' |
42 | import { VideoFileModel } from '../video/video-file' | ||
42 | 43 | ||
43 | enum ScopeNames { | 44 | enum ScopeNames { |
44 | WITH_VIDEO_CHANNEL = 'WITH_VIDEO_CHANNEL' | 45 | WITH_VIDEO_CHANNEL = 'WITH_VIDEO_CHANNEL' |
@@ -393,4 +394,15 @@ export class UserModel extends Model<UserModel> { | |||
393 | return parseInt(total, 10) | 394 | return parseInt(total, 10) |
394 | }) | 395 | }) |
395 | } | 396 | } |
397 | |||
398 | static autocomplete (search: string) { | ||
399 | return UserModel.findAll({ | ||
400 | where: { | ||
401 | username: { | ||
402 | [Sequelize.Op.like]: `%${search}%` | ||
403 | } | ||
404 | } | ||
405 | }) | ||
406 | .then(u => u.map(u => u.username)) | ||
407 | } | ||
396 | } | 408 | } |