]>
Commit | Line | Data |
---|---|---|
50d6de9c | 1 | import { Account as ServerAccount } from '../../../../../shared/models/actors/account.model' |
b1fa3eba | 2 | import { Avatar } from '../../../../../shared/models/avatars/avatar.model' |
c5911fd3 | 3 | import { getAbsoluteAPIUrl } from '../misc/utils' |
b1fa3eba C |
4 | |
5 | export class Account implements ServerAccount { | |
6 | id: number | |
7 | uuid: string | |
4cb6d457 | 8 | url: string |
b1fa3eba | 9 | name: string |
c5911fd3 | 10 | displayName: string |
2422c46b | 11 | description: string |
b1fa3eba C |
12 | host: string |
13 | followingCount: number | |
14 | followersCount: number | |
15 | createdAt: Date | |
16 | updatedAt: Date | |
17 | avatar: Avatar | |
18 | ||
c5911fd3 C |
19 | static GET_ACCOUNT_AVATAR_URL (account: Account) { |
20 | const absoluteAPIUrl = getAbsoluteAPIUrl() | |
b1fa3eba | 21 | |
c5911fd3 C |
22 | if (account && account.avatar) return absoluteAPIUrl + account.avatar.path |
23 | ||
24 | return window.location.origin + '/client/assets/images/default-avatar.png' | |
b1fa3eba | 25 | } |
76d36e0b C |
26 | |
27 | static CREATE_BY_STRING (accountName: string, host: string) { | |
28 | const absoluteAPIUrl = getAbsoluteAPIUrl() | |
29 | const thisHost = new URL(absoluteAPIUrl).host | |
30 | ||
31 | if (host.trim() === thisHost) return accountName | |
32 | ||
33 | return accountName + '@' + host | |
34 | } | |
b1fa3eba | 35 | } |