]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/users/user.model.ts
Begin video watch design
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / users / user.model.ts
CommitLineData
2295ce6c 1import { hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared'
b1fa3eba 2import { Account } from '../account/account.model'
69f616ab 3
404b54e1
C
4export type UserConstructorHash = {
5 id: number,
6 username: string,
7 email: string,
8 role: UserRole,
9 videoQuota?: number,
10 displayNSFW?: boolean,
11 createdAt?: Date,
2295ce6c 12 account?: Account,
404b54e1
C
13 videoChannels?: VideoChannel[]
14}
69f616ab 15export class User implements UserServerModel {
df98563e
C
16 id: number
17 username: string
18 email: string
19 role: UserRole
20 displayNSFW: boolean
b0f9f39e 21 videoQuota: number
2295ce6c 22 account: Account
404b54e1 23 videoChannels: VideoChannel[]
df98563e 24 createdAt: Date
7da18e44 25
404b54e1 26 constructor (hash: UserConstructorHash) {
df98563e
C
27 this.id = hash.id
28 this.username = hash.username
29 this.email = hash.email
30 this.role = hash.role
1e1265b3 31 this.account = hash.account
404b54e1
C
32
33 if (hash.videoChannels !== undefined) {
34 this.videoChannels = hash.videoChannels
35 }
44c5275e 36
b0f9f39e
C
37 if (hash.videoQuota !== undefined) {
38 this.videoQuota = hash.videoQuota
39 }
40
41 if (hash.displayNSFW !== undefined) {
42 this.displayNSFW = hash.displayNSFW
43 }
44
45 if (hash.createdAt !== undefined) {
df98563e 46 this.createdAt = hash.createdAt
44c5275e 47 }
7da18e44
C
48 }
49
954605a8
C
50 hasRight (right: UserRight) {
51 return hasUserRight(this.role, right)
7da18e44 52 }
2295ce6c
C
53
54 getAvatarPath () {
b1fa3eba 55 return Account.GET_ACCOUNT_AVATAR_PATH(this.account)
2295ce6c 56 }
7da18e44 57}