]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/core/users/user.model.ts
Implement abuses check params
[github/Chocobozzz/PeerTube.git] / client / src / app / core / users / user.model.ts
CommitLineData
67ed6552 1import { Account } from '@app/shared/shared-main/account/account.model'
d3217560 2import {
67ed6552 3 Avatar,
d3217560 4 hasUserRight,
67ed6552 5 NSFWPolicyType,
d3217560 6 User as UserServerModel,
67ed6552 7 UserAdminFlag,
d3217560
RK
8 UserNotificationSetting,
9 UserRight,
67ed6552
C
10 UserRole,
11 VideoChannel
12} from '@shared/models'
69f616ab
C
13
14export class User implements UserServerModel {
d3217560
RK
15 static KEYS = {
16 ID: 'id',
17 ROLE: 'role',
18 EMAIL: 'email',
19 VIDEOS_HISTORY_ENABLED: 'videos-history-enabled',
20 USERNAME: 'username',
21 NSFW_POLICY: 'nsfw_policy',
22 WEBTORRENT_ENABLED: 'peertube-videojs-' + 'webtorrent_enabled',
23 AUTO_PLAY_VIDEO: 'auto_play_video',
24 SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO: 'auto_play_next_video',
25 AUTO_PLAY_VIDEO_PLAYLIST: 'auto_play_video_playlist',
26 THEME: 'last_active_theme',
27 VIDEO_LANGUAGES: 'video_languages'
28 }
29
df98563e
C
30 id: number
31 username: string
32 email: string
0ba5f5ba 33 pendingEmail: string | null
43d0ea7f 34
fc2ec87a 35 emailVerified: boolean
0883b324 36 nsfwPolicy: NSFWPolicyType
276d9652 37
43d0ea7f 38 adminFlags?: UserAdminFlag
1eddc9a7 39
7efe153b 40 autoPlayVideo: boolean
6aa54148 41 autoPlayNextVideo: boolean
bee29df8 42 autoPlayNextVideoPlaylist: boolean
43d0ea7f 43 webTorrentEnabled: boolean
276d9652 44 videosHistoryEnabled: boolean
3caf77d3 45 videoLanguages: string[]
276d9652 46
43d0ea7f
C
47 role: UserRole
48 roleLabel: string
49
b0f9f39e 50 videoQuota: number
bee0abff 51 videoQuotaDaily: number
43d0ea7f
C
52 videoQuotaUsed?: number
53 videoQuotaUsedDaily?: number
76314386
RK
54 videosCount?: number
55 videoAbusesCount?: number
56 videoAbusesAcceptedCount?: number
57 videoAbusesCreatedCount?: number
58 videoCommentsCount?: number
7da18e44 59
7cd4d2ba
C
60 theme: string
61
43d0ea7f
C
62 account: Account
63 notificationSettings?: UserNotificationSetting
64 videoChannels?: VideoChannel[]
1eddc9a7 65
eacb25c4
C
66 blocked: boolean
67 blockedReason?: string
68
43d0ea7f
C
69 noInstanceConfigWarningModal: boolean
70 noWelcomeModal: boolean
71
8bb71f2e
C
72 pluginAuth: string | null
73
3cc665f4
C
74 lastLoginDate: Date | null
75
43d0ea7f 76 createdAt: Date
2f1548fd 77
276d9652 78 constructor (hash: Partial<UserServerModel>) {
df98563e
C
79 this.id = hash.id
80 this.username = hash.username
81 this.email = hash.email
1eddc9a7 82
df98563e 83 this.role = hash.role
ad9e39fb 84
eacb25c4 85 this.videoChannels = hash.videoChannels
43d0ea7f 86
eacb25c4 87 this.videoQuota = hash.videoQuota
bee0abff 88 this.videoQuotaDaily = hash.videoQuotaDaily
43d0ea7f
C
89 this.videoQuotaUsed = hash.videoQuotaUsed
90 this.videoQuotaUsedDaily = hash.videoQuotaUsedDaily
76314386
RK
91 this.videosCount = hash.videosCount
92 this.videoAbusesCount = hash.videoAbusesCount
93 this.videoAbusesAcceptedCount = hash.videoAbusesAcceptedCount
94 this.videoAbusesCreatedCount = hash.videoAbusesCreatedCount
95 this.videoCommentsCount = hash.videoCommentsCount
43d0ea7f 96
eacb25c4 97 this.nsfwPolicy = hash.nsfwPolicy
ed638e53 98 this.webTorrentEnabled = hash.webTorrentEnabled
eacb25c4 99 this.autoPlayVideo = hash.autoPlayVideo
d3217560
RK
100 this.autoPlayNextVideo = hash.autoPlayNextVideo
101 this.autoPlayNextVideoPlaylist = hash.autoPlayNextVideoPlaylist
102 this.videosHistoryEnabled = hash.videosHistoryEnabled
103 this.videoLanguages = hash.videoLanguages
1eddc9a7 104
7cd4d2ba
C
105 this.theme = hash.theme
106
1eddc9a7
C
107 this.adminFlags = hash.adminFlags
108
eacb25c4
C
109 this.blocked = hash.blocked
110 this.blockedReason = hash.blockedReason
111
43d0ea7f
C
112 this.noInstanceConfigWarningModal = hash.noInstanceConfigWarningModal
113 this.noWelcomeModal = hash.noWelcomeModal
114
2f1548fd
C
115 this.notificationSettings = hash.notificationSettings
116
43d0ea7f
C
117 this.createdAt = hash.createdAt
118
8bb71f2e 119 this.pluginAuth = hash.pluginAuth
3cc665f4 120 this.lastLoginDate = hash.lastLoginDate
8bb71f2e 121
ad9e39fb
C
122 if (hash.account !== undefined) {
123 this.account = new Account(hash.account)
124 }
52d9f792
C
125 }
126
127 get accountAvatarUrl () {
128 if (!this.account) return ''
d3e91a5f 129
52d9f792 130 return this.account.avatarUrl
7da18e44
C
131 }
132
954605a8
C
133 hasRight (right: UserRight) {
134 return hasUserRight(this.role, right)
7da18e44 135 }
2295ce6c 136
ce5496d6
C
137 patch (obj: UserServerModel) {
138 for (const key of Object.keys(obj)) {
139 this[key] = obj[key]
140 }
d3e91a5f 141
ad9e39fb
C
142 if (obj.account !== undefined) {
143 this.account = new Account(obj.account)
144 }
d3e91a5f
C
145 }
146
0c237b19 147 updateAccountAvatar (newAccountAvatar: Avatar) {
52d9f792 148 this.account.updateAvatar(newAccountAvatar)
ce5496d6 149 }
7da18e44 150}