-import { hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared'
-import { Account } from '../account/account.model'
+import { Account, hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared'
import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type'
+import { Actor } from '@app/shared/actor/actor.model'
export type UserConstructorHash = {
id: number,
account: Account
videoChannels: VideoChannel[]
createdAt: Date
+ accountAvatarUrl: string
constructor (hash: UserConstructorHash) {
this.id = hash.id
if (hash.createdAt !== undefined) {
this.createdAt = hash.createdAt
}
+
+ this.updateComputedAttributes()
}
hasRight (right: UserRight) {
return hasUserRight(this.role, right)
}
- getAvatarUrl () {
- return Account.GET_ACCOUNT_AVATAR_URL(this.account)
- }
-
patch (obj: UserServerModel) {
for (const key of Object.keys(obj)) {
this[key] = obj[key]
}
+
+ this.updateComputedAttributes()
+ }
+
+ private updateComputedAttributes () {
+ this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)
}
}