aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/account')
-rw-r--r--server/models/account/user.ts32
1 files changed, 17 insertions, 15 deletions
diff --git a/server/models/account/user.ts b/server/models/account/user.ts
index 4b13e47a0..680b1d52d 100644
--- a/server/models/account/user.ts
+++ b/server/models/account/user.ts
@@ -23,13 +23,13 @@ import {
23 isUserAutoPlayVideoValid, 23 isUserAutoPlayVideoValid,
24 isUserBlockedReasonValid, 24 isUserBlockedReasonValid,
25 isUserBlockedValid, 25 isUserBlockedValid,
26 isUserNSFWPolicyValid,
27 isUserEmailVerifiedValid, 26 isUserEmailVerifiedValid,
27 isUserNSFWPolicyValid,
28 isUserPasswordValid, 28 isUserPasswordValid,
29 isUserRoleValid, 29 isUserRoleValid,
30 isUserUsernameValid, 30 isUserUsernameValid,
31 isUserVideoQuotaValid, 31 isUserVideoQuotaDailyValid,
32 isUserVideoQuotaDailyValid 32 isUserVideoQuotaValid
33} from '../../helpers/custom-validators/users' 33} from '../../helpers/custom-validators/users'
34import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto' 34import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto'
35import { OAuthTokenModel } from '../oauth/oauth-token' 35import { OAuthTokenModel } from '../oauth/oauth-token'
@@ -39,7 +39,6 @@ import { AccountModel } from './account'
39import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type' 39import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type'
40import { values } from 'lodash' 40import { values } from 'lodash'
41import { NSFW_POLICY_TYPES } from '../../initializers' 41import { NSFW_POLICY_TYPES } from '../../initializers'
42import { VideoFileModel } from '../video/video-file'
43 42
44enum ScopeNames { 43enum ScopeNames {
45 WITH_VIDEO_CHANNEL = 'WITH_VIDEO_CHANNEL' 44 WITH_VIDEO_CHANNEL = 'WITH_VIDEO_CHANNEL'
@@ -296,6 +295,20 @@ export class UserModel extends Model<UserModel> {
296 } 295 }
297 } 296 }
298 297
298 static autoComplete (search: string) {
299 const query = {
300 where: {
301 username: {
302 [ Sequelize.Op.like ]: `%${search}%`
303 }
304 },
305 limit: 10
306 }
307
308 return UserModel.findAll(query)
309 .then(u => u.map(u => u.username))
310 }
311
299 hasRight (right: UserRight) { 312 hasRight (right: UserRight) {
300 return hasUserRight(this.role, right) 313 return hasUserRight(this.role, right)
301 } 314 }
@@ -394,15 +407,4 @@ export class UserModel extends Model<UserModel> {
394 return parseInt(total, 10) 407 return parseInt(total, 10)
395 }) 408 })
396 } 409 }
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 }
408} 410}