]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/users/user.model.ts
Fix e2e tests in parallel
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / users / user.model.ts
CommitLineData
2f1548fd 1import { hasUserRight, User as UserServerModel, UserNotificationSetting, UserRight, UserRole, VideoChannel } from '../../../../../shared'
0883b324 2import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type'
ad9e39fb 3import { Account } from '@app/shared/account/account.model'
0c237b19 4import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
1eddc9a7 5import { UserAdminFlag } from '@shared/models/users/user-flag.model'
69f616ab
C
6
7export class User implements UserServerModel {
df98563e
C
8 id: number
9 username: string
10 email: string
0ba5f5ba 11 pendingEmail: string | null
fc2ec87a 12 emailVerified: boolean
0883b324 13 nsfwPolicy: NSFWPolicyType
276d9652 14
1eddc9a7
C
15 role: UserRole
16 roleLabel: string
17
ed638e53 18 webTorrentEnabled: boolean
7efe153b 19 autoPlayVideo: boolean
276d9652
C
20 videosHistoryEnabled: boolean
21
b0f9f39e 22 videoQuota: number
bee0abff 23 videoQuotaDaily: number
2295ce6c 24 account: Account
404b54e1 25 videoChannels: VideoChannel[]
df98563e 26 createdAt: Date
7da18e44 27
1eddc9a7
C
28 adminFlags?: UserAdminFlag
29
eacb25c4
C
30 blocked: boolean
31 blockedReason?: string
32
2f1548fd
C
33 notificationSettings?: UserNotificationSetting
34
276d9652 35 constructor (hash: Partial<UserServerModel>) {
df98563e
C
36 this.id = hash.id
37 this.username = hash.username
38 this.email = hash.email
1eddc9a7 39
df98563e 40 this.role = hash.role
ad9e39fb 41
eacb25c4
C
42 this.videoChannels = hash.videoChannels
43 this.videoQuota = hash.videoQuota
bee0abff 44 this.videoQuotaDaily = hash.videoQuotaDaily
eacb25c4 45 this.nsfwPolicy = hash.nsfwPolicy
ed638e53 46 this.webTorrentEnabled = hash.webTorrentEnabled
276d9652 47 this.videosHistoryEnabled = hash.videosHistoryEnabled
eacb25c4
C
48 this.autoPlayVideo = hash.autoPlayVideo
49 this.createdAt = hash.createdAt
1eddc9a7
C
50
51 this.adminFlags = hash.adminFlags
52
eacb25c4
C
53 this.blocked = hash.blocked
54 this.blockedReason = hash.blockedReason
55
2f1548fd
C
56 this.notificationSettings = hash.notificationSettings
57
ad9e39fb
C
58 if (hash.account !== undefined) {
59 this.account = new Account(hash.account)
60 }
52d9f792
C
61 }
62
63 get accountAvatarUrl () {
64 if (!this.account) return ''
d3e91a5f 65
52d9f792 66 return this.account.avatarUrl
7da18e44
C
67 }
68
954605a8
C
69 hasRight (right: UserRight) {
70 return hasUserRight(this.role, right)
7da18e44 71 }
2295ce6c 72
ce5496d6
C
73 patch (obj: UserServerModel) {
74 for (const key of Object.keys(obj)) {
75 this[key] = obj[key]
76 }
d3e91a5f 77
ad9e39fb
C
78 if (obj.account !== undefined) {
79 this.account = new Account(obj.account)
80 }
d3e91a5f
C
81 }
82
0c237b19 83 updateAccountAvatar (newAccountAvatar: Avatar) {
52d9f792 84 this.account.updateAvatar(newAccountAvatar)
ce5496d6 85 }
7da18e44 86}