]>
Commit | Line | Data |
---|---|---|
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 | description: string | |
12 | host: string | |
13 | followingCount: number | |
14 | followersCount: number | |
15 | createdAt: Date | |
16 | updatedAt: Date | |
17 | avatar: Avatar | |
18 | ||
19 | static GET_ACCOUNT_AVATAR_URL (account: Account) { | |
20 | const absoluteAPIUrl = getAbsoluteAPIUrl() | |
21 | ||
22 | if (account && account.avatar) return absoluteAPIUrl + account.avatar.path | |
23 | ||
24 | return window.location.origin + '/client/assets/images/default-avatar.png' | |
25 | } | |
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 | } | |
35 | } |