From 7efe153b0bc23e596d5019b9fb3e3e32b6cfeccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9as=20Livet?= Date: Tue, 19 Dec 2017 10:45:49 +0100 Subject: 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 --- server/models/account/user.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'server/models') 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 { } from '../../helpers' import { isUserDisplayNSFWValid, isUserPasswordValid, isUserRoleValid, isUserUsernameValid, - isUserVideoQuotaValid + isUserVideoQuotaValid, isUserAutoPlayVideoValid } from '../../helpers/custom-validators/users' import { OAuthTokenModel } from '../oauth/oauth-token' import { getSort, throwIfNotValid } from '../utils' @@ -82,6 +82,12 @@ export class UserModel extends Model { @Column displayNSFW: boolean + @AllowNull(false) + @Default(true) + @Is('UserAutoPlayVideo', value => throwIfNotValid(value, isUserAutoPlayVideoValid, 'auto play video boolean')) + @Column + autoPlayVideo: boolean + @AllowNull(false) @Is('UserRole', value => throwIfNotValid(value, isUserRoleValid, 'role')) @Column @@ -223,6 +229,7 @@ export class UserModel extends Model { username: this.username, email: this.email, displayNSFW: this.displayNSFW, + autoPlayVideo: this.autoPlayVideo, role: this.role, roleLabel: USER_ROLE_LABELS[ this.role ], videoQuota: this.videoQuota, -- cgit v1.2.3