]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/users/user.model.ts
Implement auto follow in client
[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 20 videosHistoryEnabled: boolean
3caf77d3 21 videoLanguages: string[]
276d9652 22
b0f9f39e 23 videoQuota: number
bee0abff 24 videoQuotaDaily: number
2295ce6c 25 account: Account
404b54e1 26 videoChannels: VideoChannel[]
df98563e 27 createdAt: Date
7da18e44 28
7cd4d2ba
C
29 theme: string
30
1eddc9a7
C
31 adminFlags?: UserAdminFlag
32
eacb25c4
C
33 blocked: boolean
34 blockedReason?: string
35
2f1548fd
C
36 notificationSettings?: UserNotificationSetting
37
276d9652 38 constructor (hash: Partial<UserServerModel>) {
df98563e
C
39 this.id = hash.id
40 this.username = hash.username
41 this.email = hash.email
1eddc9a7 42
df98563e 43 this.role = hash.role
ad9e39fb 44
eacb25c4
C
45 this.videoChannels = hash.videoChannels
46 this.videoQuota = hash.videoQuota
bee0abff 47 this.videoQuotaDaily = hash.videoQuotaDaily
eacb25c4 48 this.nsfwPolicy = hash.nsfwPolicy
ed638e53 49 this.webTorrentEnabled = hash.webTorrentEnabled
276d9652 50 this.videosHistoryEnabled = hash.videosHistoryEnabled
eacb25c4
C
51 this.autoPlayVideo = hash.autoPlayVideo
52 this.createdAt = hash.createdAt
1eddc9a7 53
7cd4d2ba
C
54 this.theme = hash.theme
55
1eddc9a7
C
56 this.adminFlags = hash.adminFlags
57
eacb25c4
C
58 this.blocked = hash.blocked
59 this.blockedReason = hash.blockedReason
60
2f1548fd
C
61 this.notificationSettings = hash.notificationSettings
62
ad9e39fb
C
63 if (hash.account !== undefined) {
64 this.account = new Account(hash.account)
65 }
52d9f792
C
66 }
67
68 get accountAvatarUrl () {
69 if (!this.account) return ''
d3e91a5f 70
52d9f792 71 return this.account.avatarUrl
7da18e44
C
72 }
73
954605a8
C
74 hasRight (right: UserRight) {
75 return hasUserRight(this.role, right)
7da18e44 76 }
2295ce6c 77
ce5496d6
C
78 patch (obj: UserServerModel) {
79 for (const key of Object.keys(obj)) {
80 this[key] = obj[key]
81 }
d3e91a5f 82
ad9e39fb
C
83 if (obj.account !== undefined) {
84 this.account = new Account(obj.account)
85 }
d3e91a5f
C
86 }
87
0c237b19 88 updateAccountAvatar (newAccountAvatar: Avatar) {
52d9f792 89 this.account.updateAvatar(newAccountAvatar)
ce5496d6 90 }
7da18e44 91}