aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account/user.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/account/user.ts')
-rw-r--r--server/models/account/user.ts14
1 files changed, 8 insertions, 6 deletions
diff --git a/server/models/account/user.ts b/server/models/account/user.ts
index 8afd246b2..56af2f30a 100644
--- a/server/models/account/user.ts
+++ b/server/models/account/user.ts
@@ -21,7 +21,7 @@ import { hasUserRight, USER_ROLE_LABELS, UserRight } from '../../../shared'
21import { User, UserRole } from '../../../shared/models/users' 21import { User, UserRole } from '../../../shared/models/users'
22import { 22import {
23 isUserAutoPlayVideoValid, 23 isUserAutoPlayVideoValid,
24 isUserDisplayNSFWValid, 24 isUserNSFWPolicyValid,
25 isUserPasswordValid, 25 isUserPasswordValid,
26 isUserRoleValid, 26 isUserRoleValid,
27 isUserUsernameValid, 27 isUserUsernameValid,
@@ -32,6 +32,9 @@ import { OAuthTokenModel } from '../oauth/oauth-token'
32import { getSort, throwIfNotValid } from '../utils' 32import { getSort, throwIfNotValid } from '../utils'
33import { VideoChannelModel } from '../video/video-channel' 33import { VideoChannelModel } from '../video/video-channel'
34import { AccountModel } from './account' 34import { AccountModel } from './account'
35import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type'
36import { values } from 'lodash'
37import { NSFW_POLICY_TYPES } from '../../initializers'
35 38
36@DefaultScope({ 39@DefaultScope({
37 include: [ 40 include: [
@@ -83,10 +86,9 @@ export class UserModel extends Model<UserModel> {
83 email: string 86 email: string
84 87
85 @AllowNull(false) 88 @AllowNull(false)
86 @Default(false) 89 @Is('UserNSFWPolicy', value => throwIfNotValid(value, isUserNSFWPolicyValid, 'NSFW policy'))
87 @Is('UserDisplayNSFW', value => throwIfNotValid(value, isUserDisplayNSFWValid, 'display NSFW boolean')) 90 @Column(DataType.ENUM(values(NSFW_POLICY_TYPES)))
88 @Column 91 nsfwPolicy: NSFWPolicyType
89 displayNSFW: boolean
90 92
91 @AllowNull(false) 93 @AllowNull(false)
92 @Default(true) 94 @Default(true)
@@ -265,7 +267,7 @@ export class UserModel extends Model<UserModel> {
265 id: this.id, 267 id: this.id,
266 username: this.username, 268 username: this.username,
267 email: this.email, 269 email: this.email,
268 displayNSFW: this.displayNSFW, 270 nsfwPolicy: this.nsfwPolicy,
269 autoPlayVideo: this.autoPlayVideo, 271 autoPlayVideo: this.autoPlayVideo,
270 role: this.role, 272 role: this.role,
271 roleLabel: USER_ROLE_LABELS[ this.role ], 273 roleLabel: USER_ROLE_LABELS[ this.role ],