]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/shared/users/user.model.ts
Adapt client with video channels
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / users / user.model.ts
1 import {
2 User as UserServerModel,
3 UserRole,
4 VideoChannel
5 } from '../../../../../shared'
6
7 export type UserConstructorHash = {
8 id: number,
9 username: string,
10 email: string,
11 role: UserRole,
12 videoQuota?: number,
13 displayNSFW?: boolean,
14 createdAt?: Date,
15 author?: {
16 id: number
17 uuid: string
18 },
19 videoChannels?: VideoChannel[]
20 }
21 export class User implements UserServerModel {
22 id: number
23 username: string
24 email: string
25 role: UserRole
26 displayNSFW: boolean
27 videoQuota: number
28 author: {
29 id: number
30 uuid: string
31 }
32 videoChannels: VideoChannel[]
33 createdAt: Date
34
35 constructor (hash: UserConstructorHash) {
36 this.id = hash.id
37 this.username = hash.username
38 this.email = hash.email
39 this.role = hash.role
40 this.author = hash.author
41
42 if (hash.videoChannels !== undefined) {
43 this.videoChannels = hash.videoChannels
44 }
45
46 if (hash.videoQuota !== undefined) {
47 this.videoQuota = hash.videoQuota
48 }
49
50 if (hash.displayNSFW !== undefined) {
51 this.displayNSFW = hash.displayNSFW
52 }
53
54 if (hash.createdAt !== undefined) {
55 this.createdAt = hash.createdAt
56 }
57 }
58
59 isAdmin () {
60 return this.role === 'admin'
61 }
62 }