diff options
Diffstat (limited to 'server/models/account/user.ts')
-rw-r--r-- | server/models/account/user.ts | 14 |
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' | |||
21 | import { User, UserRole } from '../../../shared/models/users' | 21 | import { User, UserRole } from '../../../shared/models/users' |
22 | import { | 22 | import { |
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' | |||
32 | import { getSort, throwIfNotValid } from '../utils' | 32 | import { getSort, throwIfNotValid } from '../utils' |
33 | import { VideoChannelModel } from '../video/video-channel' | 33 | import { VideoChannelModel } from '../video/video-channel' |
34 | import { AccountModel } from './account' | 34 | import { AccountModel } from './account' |
35 | import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type' | ||
36 | import { values } from 'lodash' | ||
37 | import { 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 ], |