X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=client%2Fsrc%2Fapp%2Fshared%2Fusers%2Fuser.model.ts;h=2bdc48a1dc81a381ba0cda7915e7f0069aca296d;hb=03e12d7c4954e1071fdeb7ef362ea5c3965d4075;hp=7beea5910958aa9638715bdb465350420e830413;hpb=404b54e14f6623c1644a8c87ca22f4bab98d5484;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts index 7beea5910..2bdc48a1d 100644 --- a/client/src/app/shared/users/user.model.ts +++ b/client/src/app/shared/users/user.model.ts @@ -1,8 +1,6 @@ -import { - User as UserServerModel, - UserRole, - VideoChannel -} from '../../../../../shared' +import { hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared' +import { Account } from '../account/account.model' +import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' export type UserConstructorHash = { id: number, @@ -10,12 +8,10 @@ export type UserConstructorHash = { email: string, role: UserRole, videoQuota?: number, - displayNSFW?: boolean, + nsfwPolicy?: NSFWPolicyType, + autoPlayVideo?: boolean, createdAt?: Date, - author?: { - id: number - uuid: string - }, + account?: Account, videoChannels?: VideoChannel[] } export class User implements UserServerModel { @@ -23,12 +19,10 @@ export class User implements UserServerModel { username: string email: string role: UserRole - displayNSFW: boolean + nsfwPolicy: NSFWPolicyType + autoPlayVideo: boolean videoQuota: number - author: { - id: number - uuid: string - } + account: Account videoChannels: VideoChannel[] createdAt: Date @@ -37,7 +31,7 @@ export class User implements UserServerModel { this.username = hash.username this.email = hash.email this.role = hash.role - this.author = hash.author + this.account = hash.account if (hash.videoChannels !== undefined) { this.videoChannels = hash.videoChannels @@ -47,8 +41,12 @@ export class User implements UserServerModel { this.videoQuota = hash.videoQuota } - if (hash.displayNSFW !== undefined) { - this.displayNSFW = hash.displayNSFW + if (hash.nsfwPolicy !== undefined) { + this.nsfwPolicy = hash.nsfwPolicy + } + + if (hash.autoPlayVideo !== undefined) { + this.autoPlayVideo = hash.autoPlayVideo } if (hash.createdAt !== undefined) { @@ -56,7 +54,17 @@ export class User implements UserServerModel { } } - isAdmin () { - return this.role === 'admin' + 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] + } } }