]>
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 | ||
0626e7af C |
19 | constructor (hash: ServerAccount) { |
20 | this.id = hash.id | |
21 | this.uuid = hash.uuid | |
22 | this.url = hash.url | |
23 | this.name = hash.name | |
24 | this.displayName = hash.displayName | |
25 | this.description = hash.description | |
26 | this.host = hash.host | |
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 | |
32 | } | |
33 | ||
c5911fd3 C |
34 | static GET_ACCOUNT_AVATAR_URL (account: Account) { |
35 | const absoluteAPIUrl = getAbsoluteAPIUrl() | |
b1fa3eba | 36 | |
c5911fd3 C |
37 | if (account && account.avatar) return absoluteAPIUrl + account.avatar.path |
38 | ||
39 | return window.location.origin + '/client/assets/images/default-avatar.png' | |
b1fa3eba | 40 | } |
76d36e0b C |
41 | |
42 | static CREATE_BY_STRING (accountName: string, host: string) { | |
43 | const absoluteAPIUrl = getAbsoluteAPIUrl() | |
44 | const thisHost = new URL(absoluteAPIUrl).host | |
45 | ||
46 | if (host.trim() === thisHost) return accountName | |
47 | ||
48 | return accountName + '@' + host | |
49 | } | |
b1fa3eba | 50 | } |