From 0883b3245bf0deb9106c4041e9afbd3521b79280 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 19 Apr 2018 11:01:34 +0200 Subject: Add ability to choose what policy we have for NSFW videos There is a global instance setting and a per user setting --- client/src/app/shared/video/video-miniature.component.html | 4 ++-- client/src/app/shared/video/video-miniature.component.ts | 7 +++++-- client/src/app/shared/video/video.model.ts | 13 ++++++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) (limited to 'client/src/app/shared/video') diff --git a/client/src/app/shared/video/video-miniature.component.html b/client/src/app/shared/video/video-miniature.component.html index f28e9b8d9..233432142 100644 --- a/client/src/app/shared/video/video-miniature.component.html +++ b/client/src/app/shared/video/video-miniature.component.html @@ -1,11 +1,11 @@
- +
{{ video.name }} diff --git a/client/src/app/shared/video/video-miniature.component.ts b/client/src/app/shared/video/video-miniature.component.ts index 4d79a74bb..d3f6dc1f6 100644 --- a/client/src/app/shared/video/video-miniature.component.ts +++ b/client/src/app/shared/video/video-miniature.component.ts @@ -1,6 +1,7 @@ import { Component, Input } from '@angular/core' import { User } from '../users' import { Video } from './video.model' +import { ServerService } from '@app/core' @Component({ selector: 'my-video-miniature', @@ -11,7 +12,9 @@ export class VideoMiniatureComponent { @Input() user: User @Input() video: Video - isVideoNSFWForThisUser () { - return this.video.isVideoNSFWForUser(this.user) + constructor (private serverService: ServerService) { } + + isVideoBlur () { + return this.video.isVideoNSFWForUser(this.user, this.serverService.getConfig()) } } diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts index 0c02cbcb9..adc248a1e 100644 --- a/client/src/app/shared/video/video.model.ts +++ b/client/src/app/shared/video/video.model.ts @@ -4,6 +4,7 @@ import { Video as VideoServerModel } from '../../../../../shared' import { Avatar } from '../../../../../shared/models/avatars/avatar.model' import { VideoConstant } from '../../../../../shared/models/videos/video.model' import { getAbsoluteAPIUrl } from '../misc/utils' +import { ServerConfig } from '../../../../../shared/models' export class Video implements VideoServerModel { by: string @@ -83,8 +84,14 @@ export class Video implements VideoServerModel { this.by = Account.CREATE_BY_STRING(hash.account.name, hash.account.host) } - 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)) + isVideoNSFWForUser (user: User, serverConfig: ServerConfig) { + // Video is not NSFW, skip + if (this.nsfw === false) return false + + // Return user setting if logged in + if (user) return user.nsfwPolicy !== 'display' + + // Return default instance config + return serverConfig.instance.defaultNSFWPolicy !== 'display' } } -- cgit v1.2.3