From 92fb909c9b4a92a00b0d0da7629e6fb003de281b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 4 Apr 2017 21:37:03 +0200 Subject: Client: Handle NSFW video --- client/src/app/videos/shared/video.model.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'client/src/app/videos/shared/video.model.ts') diff --git a/client/src/app/videos/shared/video.model.ts b/client/src/app/videos/shared/video.model.ts index 5ed622dce..3c588c446 100644 --- a/client/src/app/videos/shared/video.model.ts +++ b/client/src/app/videos/shared/video.model.ts @@ -1,3 +1,5 @@ +import { User } from '../../shared'; + export class Video { author: string; by: string; @@ -16,6 +18,7 @@ export class Video { views: number; likes: number; dislikes: number; + nsfw: boolean; private static createByString(author: string, podHost: string) { return author + '@' + podHost; @@ -47,6 +50,7 @@ export class Video { views: number, likes: number, dislikes: number, + nsfw: boolean }) { this.author = hash.author; this.createdAt = new Date(hash.createdAt); @@ -64,11 +68,17 @@ export class Video { this.views = hash.views; this.likes = hash.likes; this.dislikes = hash.dislikes; + this.nsfw = hash.nsfw; this.by = Video.createByString(hash.author, hash.podHost); } - isRemovableBy(user) { + isRemovableBy(user: User) { return this.isLocal === true && user && this.author === user.username; } + + isVideoNSFWForUser(user: User) { + // If the video is NSFW and the user is not logged in, or the user does not want to display NSFW videos... + return (this.nsfw && (!user || user.displayNSFW === false)); + } } -- cgit v1.2.3