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'
5 export class Account implements ServerAccount {
13 followingCount: number
14 followersCount: number
19 constructor (hash: ServerAccount) {
24 this.displayName = hash.displayName
25 this.description = hash.description
27 this.followingCount = hash.followingCount
28 this.followersCount = hash.followersCount
29 this.createdAt = new Date(hash.createdAt.toString())
30 this.updatedAt = new Date(hash.updatedAt.toString())
31 this.avatar = hash.avatar
34 static GET_ACCOUNT_AVATAR_URL (account: Account) {
35 const absoluteAPIUrl = getAbsoluteAPIUrl()
37 if (account && account.avatar) return absoluteAPIUrl + account.avatar.path
39 return window.location.origin + '/client/assets/images/default-avatar.png'
42 static CREATE_BY_STRING (accountName: string, host: string) {
43 const absoluteAPIUrl = getAbsoluteAPIUrl()
44 const thisHost = new URL(absoluteAPIUrl).host
46 if (host.trim() === thisHost) return accountName
48 return accountName + '@' + host