aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/video
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/video')
-rw-r--r--client/src/app/shared/video/video-details.model.ts11
-rw-r--r--client/src/app/shared/video/video-miniature.component.html4
-rw-r--r--client/src/app/shared/video/video-miniature.component.ts7
-rw-r--r--client/src/app/shared/video/video.model.ts17
4 files changed, 21 insertions, 18 deletions
diff --git a/client/src/app/shared/video/video-details.model.ts b/client/src/app/shared/video/video-details.model.ts
index a1f7207a2..5397aa37f 100644
--- a/client/src/app/shared/video/video-details.model.ts
+++ b/client/src/app/shared/video/video-details.model.ts
@@ -1,17 +1,9 @@
1import { 1import { UserRight, VideoChannel, VideoDetails as VideoDetailsServerModel, VideoFile } from '../../../../../shared'
2 UserRight,
3 VideoChannel,
4 VideoDetails as VideoDetailsServerModel,
5 VideoFile,
6 VideoPrivacy
7} from '../../../../../shared'
8import { Account } from '../../../../../shared/models/actors' 2import { Account } from '../../../../../shared/models/actors'
9import { VideoConstant } from '../../../../../shared/models/videos/video.model'
10import { AuthUser } from '../../core' 3import { AuthUser } from '../../core'
11import { Video } from '../../shared/video/video.model' 4import { Video } from '../../shared/video/video.model'
12 5
13export class VideoDetails extends Video implements VideoDetailsServerModel { 6export class VideoDetails extends Video implements VideoDetailsServerModel {
14 privacy: VideoConstant<VideoPrivacy>
15 descriptionPath: string 7 descriptionPath: string
16 support: string 8 support: string
17 channel: VideoChannel 9 channel: VideoChannel
@@ -26,7 +18,6 @@ export class VideoDetails extends Video implements VideoDetailsServerModel {
26 constructor (hash: VideoDetailsServerModel) { 18 constructor (hash: VideoDetailsServerModel) {
27 super(hash) 19 super(hash)
28 20
29 this.privacy = hash.privacy
30 this.descriptionPath = hash.descriptionPath 21 this.descriptionPath = hash.descriptionPath
31 this.files = hash.files 22 this.files = hash.files
32 this.channel = hash.channel 23 this.channel = hash.channel
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 @@
1<div class="video-miniature"> 1<div class="video-miniature">
2 <my-video-thumbnail [video]="video" [nsfw]="isVideoNSFWForThisUser()"></my-video-thumbnail> 2 <my-video-thumbnail [video]="video" [nsfw]="isVideoBlur()"></my-video-thumbnail>
3 3
4 <div class="video-miniature-information"> 4 <div class="video-miniature-information">
5 <span class="video-miniature-name"> 5 <span class="video-miniature-name">
6 <a 6 <a
7 class="video-miniature-name" 7 class="video-miniature-name"
8 [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoNSFWForThisUser() }" 8 [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoBlur() }"
9 > 9 >
10 {{ video.name }} 10 {{ video.name }}
11 </a> 11 </a>
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 @@
1import { Component, Input } from '@angular/core' 1import { Component, Input } from '@angular/core'
2import { User } from '../users' 2import { User } from '../users'
3import { Video } from './video.model' 3import { Video } from './video.model'
4import { ServerService } from '@app/core'
4 5
5@Component({ 6@Component({
6 selector: 'my-video-miniature', 7 selector: 'my-video-miniature',
@@ -11,7 +12,9 @@ export class VideoMiniatureComponent {
11 @Input() user: User 12 @Input() user: User
12 @Input() video: Video 13 @Input() video: Video
13 14
14 isVideoNSFWForThisUser () { 15 constructor (private serverService: ServerService) { }
15 return this.video.isVideoNSFWForUser(this.user) 16
17 isVideoBlur () {
18 return this.video.isVideoNSFWForUser(this.user, this.serverService.getConfig())
16 } 19 }
17} 20}
diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts
index 0c02cbcb9..e25c172e0 100644
--- a/client/src/app/shared/video/video.model.ts
+++ b/client/src/app/shared/video/video.model.ts
@@ -1,9 +1,10 @@
1import { Account } from '@app/shared/account/account.model' 1import { Account } from '@app/shared/account/account.model'
2import { User } from '../' 2import { User } from '../'
3import { Video as VideoServerModel } from '../../../../../shared' 3import { Video as VideoServerModel, VideoPrivacy } from '../../../../../shared'
4import { Avatar } from '../../../../../shared/models/avatars/avatar.model' 4import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
5import { VideoConstant } from '../../../../../shared/models/videos/video.model' 5import { VideoConstant } from '../../../../../shared/models/videos/video.model'
6import { getAbsoluteAPIUrl } from '../misc/utils' 6import { getAbsoluteAPIUrl } from '../misc/utils'
7import { ServerConfig } from '../../../../../shared/models'
7 8
8export class Video implements VideoServerModel { 9export class Video implements VideoServerModel {
9 by: string 10 by: string
@@ -13,6 +14,7 @@ export class Video implements VideoServerModel {
13 category: VideoConstant<number> 14 category: VideoConstant<number>
14 licence: VideoConstant<number> 15 licence: VideoConstant<number>
15 language: VideoConstant<number> 16 language: VideoConstant<number>
17 privacy: VideoConstant<VideoPrivacy>
16 description: string 18 description: string
17 duration: number 19 duration: number
18 durationLabel: string 20 durationLabel: string
@@ -61,6 +63,7 @@ export class Video implements VideoServerModel {
61 this.category = hash.category 63 this.category = hash.category
62 this.licence = hash.licence 64 this.licence = hash.licence
63 this.language = hash.language 65 this.language = hash.language
66 this.privacy = hash.privacy
64 this.description = hash.description 67 this.description = hash.description
65 this.duration = hash.duration 68 this.duration = hash.duration
66 this.durationLabel = Video.createDurationString(hash.duration) 69 this.durationLabel = Video.createDurationString(hash.duration)
@@ -83,8 +86,14 @@ export class Video implements VideoServerModel {
83 this.by = Account.CREATE_BY_STRING(hash.account.name, hash.account.host) 86 this.by = Account.CREATE_BY_STRING(hash.account.name, hash.account.host)
84 } 87 }
85 88
86 isVideoNSFWForUser (user: User) { 89 isVideoNSFWForUser (user: User, serverConfig: ServerConfig) {
87 // If the video is NSFW and the user is not logged in, or the user does not want to display NSFW videos... 90 // Video is not NSFW, skip
88 return (this.nsfw && (!user || user.displayNSFW === false)) 91 if (this.nsfw === false) return false
92
93 // Return user setting if logged in
94 if (user) return user.nsfwPolicy !== 'display'
95
96 // Return default instance config
97 return serverConfig.instance.defaultNSFWPolicy !== 'display'
89 } 98 }
90} 99}