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,
13 videoChannels?: VideoChannel[]
15 export class User implements UserServerModel {
23 videoChannels: VideoChannel[]
26 constructor (hash: UserConstructorHash) {
28 this.username = hash.username
29 this.email = hash.email
31 this.account = hash.account
33 if (hash.videoChannels !== undefined) {
34 this.videoChannels = hash.videoChannels
37 if (hash.videoQuota !== undefined) {
38 this.videoQuota = hash.videoQuota
41 if (hash.displayNSFW !== undefined) {
42 this.displayNSFW = hash.displayNSFW
45 if (hash.createdAt !== undefined) {
46 this.createdAt = hash.createdAt
50 hasRight (right: UserRight) {
51 return hasUserRight(this.role, right)
55 return Account.GET_ACCOUNT_AVATAR_PATH(this.account)