]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/shared/account/account.model.ts
Refractor account by
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / account / account.model.ts
1 import { Account as ServerAccount } from '../../../../../shared/models/actors/account.model'
2 import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
3 import { getAbsoluteAPIUrl } from '../misc/utils'
4
5 export class Account implements ServerAccount {
6 id: number
7 uuid: string
8 url: string
9 name: string
10 displayName: string
11 host: string
12 followingCount: number
13 followersCount: number
14 createdAt: Date
15 updatedAt: Date
16 avatar: Avatar
17
18 static GET_ACCOUNT_AVATAR_URL (account: Account) {
19 const absoluteAPIUrl = getAbsoluteAPIUrl()
20
21 if (account && account.avatar) return absoluteAPIUrl + account.avatar.path
22
23 return window.location.origin + '/client/assets/images/default-avatar.png'
24 }
25
26 static CREATE_BY_STRING (accountName: string, host: string) {
27 const absoluteAPIUrl = getAbsoluteAPIUrl()
28 const thisHost = new URL(absoluteAPIUrl).host
29
30 if (host.trim() === thisHost) return accountName
31
32 return accountName + '@' + host
33 }
34 }