1 import { Account as ServerAccount, Actor as ServerActor, ActorImage } from '@shared/models'
2 import { Actor } from './actor.model'
4 export class Account extends Actor implements ServerAccount {
8 updatedAt: Date | string
11 nameWithHostForced: string
14 mutedByInstance: boolean
15 mutedServerByUser: boolean
16 mutedServerByInstance: boolean
20 static GET_ACTOR_AVATAR_URL (actor: { avatar?: { url?: string, path: string } }) {
21 return Actor.GET_ACTOR_AVATAR_URL(actor)
24 static GET_DEFAULT_AVATAR_URL () {
25 return `${window.location.origin}/client/assets/images/default-avatar-account.png`
28 constructor (hash: ServerAccount) {
31 this.displayName = hash.displayName
32 this.description = hash.description
33 this.userId = hash.userId
34 this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host)
35 this.nameWithHostForced = Actor.CREATE_BY_STRING(this.name, this.host, true)
37 if (hash.updatedAt) this.updatedAt = new Date(hash.updatedAt.toString())
39 this.mutedByUser = false
40 this.mutedByInstance = false
41 this.mutedServerByUser = false
42 this.mutedServerByInstance = false
45 updateAvatar (newAvatar: ActorImage) {
46 this.avatar = newAvatar