]>
Commit | Line | Data |
---|---|---|
80badf49 | 1 | import { Account as ServerAccount, ActorImage, BlockStatus } from '@shared/models' |
67ed6552 | 2 | import { Actor } from './actor.model' |
b1fa3eba | 3 | |
d3e91a5f | 4 | export class Account extends Actor implements ServerAccount { |
c5911fd3 | 5 | displayName: string |
2422c46b | 6 | description: string |
dc2b2938 C |
7 | |
8 | updatedAt: Date | string | |
9 | ||
ad9e39fb | 10 | nameWithHost: string |
e379f813 | 11 | nameWithHostForced: string |
dc2b2938 | 12 | |
65b21c96 C |
13 | mutedByUser: boolean |
14 | mutedByInstance: boolean | |
15 | mutedServerByUser: boolean | |
16 | mutedServerByInstance: boolean | |
6b738c7a | 17 | |
79bd2632 C |
18 | userId?: number |
19 | ||
126a6352 | 20 | static GET_ACTOR_AVATAR_URL (actor: { avatar?: { url?: string, path: string } }) { |
09790754 | 21 | return Actor.GET_ACTOR_AVATAR_URL(actor) |
c418d483 | 22 | } |
23 | ||
24 | static GET_DEFAULT_AVATAR_URL () { | |
25 | return `${window.location.origin}/client/assets/images/default-avatar-account.png` | |
26 | } | |
27 | ||
6b738c7a | 28 | constructor (hash: ServerAccount) { |
d3e91a5f C |
29 | super(hash) |
30 | ||
6b738c7a C |
31 | this.displayName = hash.displayName |
32 | this.description = hash.description | |
79bd2632 | 33 | this.userId = hash.userId |
ad9e39fb | 34 | this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host) |
e379f813 | 35 | this.nameWithHostForced = Actor.CREATE_BY_STRING(this.name, this.host, true) |
af5767ff | 36 | |
dc2b2938 C |
37 | if (hash.updatedAt) this.updatedAt = new Date(hash.updatedAt.toString()) |
38 | ||
65b21c96 C |
39 | this.mutedByUser = false |
40 | this.mutedByInstance = false | |
41 | this.mutedServerByUser = false | |
42 | this.mutedServerByInstance = false | |
6b738c7a | 43 | } |
c418d483 | 44 | |
f4796856 | 45 | updateAvatar (newAvatar: ActorImage) { |
c418d483 | 46 | this.avatar = newAvatar |
c418d483 | 47 | } |
48 | ||
1ea7da81 RK |
49 | resetAvatar () { |
50 | this.avatar = null | |
c418d483 | 51 | } |
80badf49 C |
52 | |
53 | updateBlockStatus (blockStatus: BlockStatus) { | |
54 | this.mutedByInstance = blockStatus.accounts[this.nameWithHostForced].blockedByServer | |
55 | this.mutedByUser = blockStatus.accounts[this.nameWithHostForced].blockedByUser | |
56 | this.mutedServerByUser = blockStatus.hosts[this.host].blockedByUser | |
57 | this.mutedServerByInstance = blockStatus.hosts[this.host].blockedByServer | |
58 | } | |
b1fa3eba | 59 | } |