aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/account
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/account')
-rw-r--r--client/src/app/shared/account/account.model.ts44
1 files changed, 4 insertions, 40 deletions
diff --git a/client/src/app/shared/account/account.model.ts b/client/src/app/shared/account/account.model.ts
index 10a70ac31..6a3c6451c 100644
--- a/client/src/app/shared/account/account.model.ts
+++ b/client/src/app/shared/account/account.model.ts
@@ -1,50 +1,14 @@
1import { Account as ServerAccount } from '../../../../../shared/models/actors/account.model' 1import { Account as ServerAccount } from '../../../../../shared/models/actors/account.model'
2import { Avatar } from '../../../../../shared/models/avatars/avatar.model' 2import { Actor } from '../actor/actor.model'
3import { getAbsoluteAPIUrl } from '../misc/utils'
4 3
5export class Account implements ServerAccount { 4export class Account extends Actor implements ServerAccount {
6 id: number
7 uuid: string
8 url: string
9 name: string
10 displayName: string 5 displayName: string
11 description: string 6 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 7
36 constructor (hash: ServerAccount) { 8 constructor (hash: ServerAccount) {
37 this.id = hash.id 9 super(hash)
38 this.uuid = hash.uuid 10
39 this.url = hash.url
40 this.name = hash.name
41 this.displayName = hash.displayName 11 this.displayName = hash.displayName
42 this.description = hash.description 12 this.description = hash.description
43 this.host = hash.host
44 this.followingCount = hash.followingCount
45 this.followersCount = hash.followersCount
46 this.createdAt = new Date(hash.createdAt.toString())
47 this.updatedAt = new Date(hash.updatedAt.toString())
48 this.avatar = hash.avatar
49 } 13 }
50} 14}