import { hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared'
-import { Account } from '../../../../../shared/models/accounts'
+import { Account } from '../account/account.model'
+import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type'
export type UserConstructorHash = {
id: number,
email: string,
role: UserRole,
videoQuota?: number,
- displayNSFW?: boolean,
+ nsfwPolicy?: NSFWPolicyType,
+ autoPlayVideo?: boolean,
createdAt?: Date,
account?: Account,
videoChannels?: VideoChannel[]
username: string
email: string
role: UserRole
- displayNSFW: boolean
+ nsfwPolicy: NSFWPolicyType
+ autoPlayVideo: boolean
videoQuota: number
account: Account
videoChannels: VideoChannel[]
this.videoQuota = hash.videoQuota
}
- if (hash.displayNSFW !== undefined) {
- this.displayNSFW = hash.displayNSFW
+ if (hash.nsfwPolicy !== undefined) {
+ this.nsfwPolicy = hash.nsfwPolicy
+ }
+
+ if (hash.autoPlayVideo !== undefined) {
+ this.autoPlayVideo = hash.autoPlayVideo
}
if (hash.createdAt !== undefined) {
return hasUserRight(this.role, right)
}
- getAvatarPath () {
- if (this.account && this.account.avatar) return this.account.avatar.path
+ getAvatarUrl () {
+ return Account.GET_ACCOUNT_AVATAR_URL(this.account)
+ }
- return API_URL + '/client/assets/images/default-avatar.png'
+ patch (obj: UserServerModel) {
+ for (const key of Object.keys(obj)) {
+ this[key] = obj[key]
+ }
}
}