aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account/user.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-04 10:22:10 +0200
committerChocobozzz <me@florianbigard.com>2018-09-04 10:49:53 +0200
commit5cf84858d49f4231cc4efec5e3132f17f65f6cf6 (patch)
treef1ff23476ff54c32c3fa34db79c11f242855d3b4 /server/models/account/user.ts
parent0b74c74abe5a44e9f564ab6adb5177ab17d28e91 (diff)
downloadPeerTube-5cf84858d49f4231cc4efec5e3132f17f65f6cf6.tar.gz
PeerTube-5cf84858d49f4231cc4efec5e3132f17f65f6cf6.tar.zst
PeerTube-5cf84858d49f4231cc4efec5e3132f17f65f6cf6.zip
Add federation to ownership change
Diffstat (limited to 'server/models/account/user.ts')
-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}