1 import { hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared'
2 import { Account } from '../account/account.model'
4 export type UserConstructorHash = {
10 displayNSFW?: boolean,
11 autoPlayVideo?: boolean,
14 videoChannels?: VideoChannel[]
16 export class User implements UserServerModel {
22 autoPlayVideo: boolean
25 videoChannels: VideoChannel[]
28 constructor (hash: UserConstructorHash) {
30 this.username = hash.username
31 this.email = hash.email
33 this.account = hash.account
35 if (hash.videoChannels !== undefined) {
36 this.videoChannels = hash.videoChannels
39 if (hash.videoQuota !== undefined) {
40 this.videoQuota = hash.videoQuota
43 if (hash.displayNSFW !== undefined) {
44 this.displayNSFW = hash.displayNSFW
47 if (hash.autoPlayVideo !== undefined) {
48 this.autoPlayVideo = hash.autoPlayVideo
51 if (hash.createdAt !== undefined) {
52 this.createdAt = hash.createdAt
56 hasRight (right: UserRight) {
57 return hasUserRight(this.role, right)
61 return Account.GET_ACCOUNT_AVATAR_URL(this.account)
64 patch (obj: UserServerModel) {
65 for (const key of Object.keys(obj)) {