aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account/user.ts
diff options
context:
space:
mode:
authorAndréas Livet <andreas.livet@gmail.com>2017-12-19 10:45:49 +0100
committerChocobozzz <me@florianbigard.com>2017-12-19 10:45:49 +0100
commit7efe153b0bc23e596d5019b9fb3e3e32b6cfeccd (patch)
tree56116e7e9f8467b78ed6dfc81827288915d31c8c /server/models/account/user.ts
parent228077efd73485a2832bb6211c9fa923158c2112 (diff)
downloadPeerTube-7efe153b0bc23e596d5019b9fb3e3e32b6cfeccd.tar.gz
PeerTube-7efe153b0bc23e596d5019b9fb3e3e32b6cfeccd.tar.zst
PeerTube-7efe153b0bc23e596d5019b9fb3e3e32b6cfeccd.zip
Enh #106 : Add an autoPlayVideo user attribute (#159)
Warning : I was not able to run the tests on my machine. It uses a different approach to handle databse connexion and didn't find where to configure it... - create a migration file to add a boolean column in user table - add autoPlayVideo attribute everywhere it is needed (both on client and server side) - add tests - add a way to configure this attribute in account-settings - use the attribute in video-watch component to actually autoplay or not the video
Diffstat (limited to 'server/models/account/user.ts')
-rw-r--r--server/models/account/user.ts9
1 files changed, 8 insertions, 1 deletions
diff --git a/server/models/account/user.ts b/server/models/account/user.ts
index 26f04dcb5..70ed61e07 100644
--- a/server/models/account/user.ts
+++ b/server/models/account/user.ts
@@ -20,7 +20,7 @@ import {
20} from '../../helpers' 20} from '../../helpers'
21import { 21import {
22 isUserDisplayNSFWValid, isUserPasswordValid, isUserRoleValid, isUserUsernameValid, 22 isUserDisplayNSFWValid, isUserPasswordValid, isUserRoleValid, isUserUsernameValid,
23 isUserVideoQuotaValid 23 isUserVideoQuotaValid, isUserAutoPlayVideoValid
24} from '../../helpers/custom-validators/users' 24} from '../../helpers/custom-validators/users'
25import { OAuthTokenModel } from '../oauth/oauth-token' 25import { OAuthTokenModel } from '../oauth/oauth-token'
26import { getSort, throwIfNotValid } from '../utils' 26import { getSort, throwIfNotValid } from '../utils'
@@ -83,6 +83,12 @@ export class UserModel extends Model<UserModel> {
83 displayNSFW: boolean 83 displayNSFW: boolean
84 84
85 @AllowNull(false) 85 @AllowNull(false)
86 @Default(true)
87 @Is('UserAutoPlayVideo', value => throwIfNotValid(value, isUserAutoPlayVideoValid, 'auto play video boolean'))
88 @Column
89 autoPlayVideo: boolean
90
91 @AllowNull(false)
86 @Is('UserRole', value => throwIfNotValid(value, isUserRoleValid, 'role')) 92 @Is('UserRole', value => throwIfNotValid(value, isUserRoleValid, 'role'))
87 @Column 93 @Column
88 role: number 94 role: number
@@ -223,6 +229,7 @@ export class UserModel extends Model<UserModel> {
223 username: this.username, 229 username: this.username,
224 email: this.email, 230 email: this.email,
225 displayNSFW: this.displayNSFW, 231 displayNSFW: this.displayNSFW,
232 autoPlayVideo: this.autoPlayVideo,
226 role: this.role, 233 role: this.role,
227 roleLabel: USER_ROLE_LABELS[ this.role ], 234 roleLabel: USER_ROLE_LABELS[ this.role ],
228 videoQuota: this.videoQuota, 235 videoQuota: this.videoQuota,