Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Add more info to NSFW confirm modal

Chocobozzz401dcafe47e9
diff --git a/client/src/app/+video-watch/video-watch.component.ts b/client/src/app/+video-watch/video-watch.component.ts
index 35f28ec9d4..b6ba33443c 100644
--- a/client/src/app/+video-watch/video-watch.component.ts
+++ b/client/src/app/+video-watch/video-watch.component.ts
@@ -522,10 +522,20 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
this.transcriptionWidgetOpened = false
}
- if (this.video.isVideoNSFWHiddenForUser(loggedInOrAnonymousUser, this.serverConfig)) {
+ if (this.video.isNSFWHiddenForUser(loggedInOrAnonymousUser, this.serverConfig)) {
const res = await this.confirmService.confirm(
- $localize`This video contains mature or explicit content. Are you sure you want to watch it?`,
- $localize`Mature or explicit content`
+ $localize`This video contains sensitive content. Are you sure you want to display the video page?`,
+ $localize`Sensitive video`,
+ {
+ confirmButtonText: $localize`Display the page`,
+ cancelButtonText: $localize`Quit that page`,
+ moreInfo: video.nsfwSummary
+ ? {
+ title: $localize`Learn more`,
+ content: video.nsfwSummary
+ }
+ : undefined
+ }
)
if (res === false) return this.location.back()
}
@@ -645,12 +655,12 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
})
}
- private isAutoplay (loggedInOrAnonymousUser: User) {
+ private isAutoplay (video: Video, loggedInOrAnonymousUser: User) {
// We'll jump to the thread id, so do not play the video
if (this.route.snapshot.params['threadId']) return false
- // Prevent autoplay if we need to warn the user
- if (this.video.isVideoNSFWWarnedForUser(loggedInOrAnonymousUser, this.serverConfig)) return false
+ // Prevent autoplay on NSFW hide/warn
+ if (video.isNSFWHiddenOrWarned(loggedInOrAnonymousUser, this.serverConfig)) return false
if (loggedInOrAnonymousUser) return loggedInOrAnonymousUser.autoPlayVideo
@@ -804,10 +814,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
return {
mode,
- autoplay: this.isAutoplay(loggedInOrAnonymousUser),
+ autoplay: this.isAutoplay(video, loggedInOrAnonymousUser),
forceAutoplay,
- duration: this.video.duration,
+ duration: video.duration,
p2pEnabled: isP2PEnabled(video, this.serverConfig, loggedInOrAnonymousUser.p2pEnabled),
startTime,
@@ -831,11 +841,11 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
!video.canBypassPassword(this.authUser),
videoPassword: () => videoPassword,
- poster: video.isVideoNSFWBlurForUser(loggedInOrAnonymousUser, this.serverConfig)
+ poster: video.isNSFWBlurForUser(loggedInOrAnonymousUser, this.serverConfig)
? null
: video.previewUrl,
- nsfwWarning: video.isVideoNSFWWarnedForUser(loggedInOrAnonymousUser, this.serverConfig)
+ nsfwWarning: video.isNSFWHiddenOrWarned(loggedInOrAnonymousUser, this.serverConfig)
? {
flags: video.nsfwFlags,
summary: video.nsfwSummary
@@ -940,7 +950,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
this.peertubePlayer.unload()
this.peertubePlayer.disable()
- if (hasPlayed || !this.video.isVideoNSFWBlurForUser(this.authUser || this.anonymousUser, this.serverConfig)) {
+ if (hasPlayed || !this.video.isNSFWBlurForUser(this.authUser || this.anonymousUser, this.serverConfig)) {
this.peertubePlayer.setPoster(this.video.previewPath)
}
}
diff --git a/client/src/app/core/confirm/confirm.service.ts b/client/src/app/core/confirm/confirm.service.ts
index 5d70c61d57..247b5080ab 100644
--- a/client/src/app/core/confirm/confirm.service.ts
+++ b/client/src/app/core/confirm/confirm.service.ts
@@ -1,11 +1,15 @@
-import { firstValueFrom, map, Observable, Subject } from 'rxjs'
import { Injectable } from '@angular/core'
+import { firstValueFrom, map, Observable, Subject } from 'rxjs'
type ConfirmOptions =
& {
title: string
message: string
errorMessage?: string
+ moreInfo?: {
+ title: string
+ content: string
+ }
confirmButtonText?: string
cancelButtonText?: string
}
@@ -32,16 +36,14 @@ export class ConfirmService {
confirm (
message: string,
title = '',
- options: {
- confirmButtonText?: string
- cancelButtonText?: string
- } = {}
+ options: Partial<Pick<ConfirmOptions, 'confirmButtonText' | 'cancelButtonText' | 'moreInfo'>> = {}
) {
this.showConfirm.next({
type: 'confirm',
title,
message,
confirmButtonText: options.confirmButtonText,
+ moreInfo: options.moreInfo,
cancelButtonText: options.cancelButtonText
})
diff --git a/client/src/app/modal/confirm.component.html b/client/src/app/modal/confirm.component.html
index ae1aa715a3..1c12e747c6 100644
--- a/client/src/app/modal/confirm.component.html
+++ b/client/src/app/modal/confirm.component.html
@@ -11,6 +11,14 @@
<div class="modal-body" >
<div [innerHtml]="message"></div>
+ @if (moreInfo) {
+ <details class="mt-3">
+ <summary i18n>{{ moreInfo.title }}</summary>
+
+ {{ moreInfo.content }}
+ </details>
+ }
+
<div *ngIf="inputLabel" class="form-group mt-3">
<label for="confirmInput">{{ inputLabel }}</label>
diff --git a/client/src/app/modal/confirm.component.ts b/client/src/app/modal/confirm.component.ts
index 2be201a267..74a73611a5 100644
--- a/client/src/app/modal/confirm.component.ts
+++ b/client/src/app/modal/confirm.component.ts
@@ -28,6 +28,9 @@ export class ConfirmComponent implements OnInit {
inputLabel = ''
inputValue = ''
+
+ moreInfo: { title: string, content: string }
+
cancelButtonText = ''
confirmButtonText = ''
@@ -46,13 +49,15 @@ export class ConfirmComponent implements OnInit {
this.expectedInputValue = ''
this.inputLabel = ''
this.inputValue = ''
+ this.moreInfo = undefined
this.confirmButtonText = ''
this.isPasswordInput = false
this.errorMessage = ''
- const { type, title, message, confirmButtonText, cancelButtonText, errorMessage } = payload
+ const { type, title, message, confirmButtonText, cancelButtonText, errorMessage, moreInfo } = payload
this.title = title
+ this.moreInfo = moreInfo
if (type === 'confirm-expected-input') {
this.inputLabel = payload.inputLabel
diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts
index 519c9493b6..0bee63d9e5 100644
--- a/client/src/app/shared/shared-main/video/video.model.ts
+++ b/client/src/app/shared/shared-main/video/video.model.ts
@@ -223,18 +223,24 @@ export class Video implements VideoServerModel {
this.comments = hash.comments
}
- isVideoNSFWWarnedForUser (user: User, serverConfig: HTMLServerConfig) {
+ isNSFWWarnedForUser (user: User, serverConfig: HTMLServerConfig) {
return isVideoNSFWWarnedForUser(this, serverConfig, user)
}
- isVideoNSFWBlurForUser (user: User, serverConfig: HTMLServerConfig) {
+ isNSFWBlurForUser (user: User, serverConfig: HTMLServerConfig) {
return isVideoNSFWBlurForUser(this, serverConfig, user)
}
- isVideoNSFWHiddenForUser (user: User, serverConfig: HTMLServerConfig) {
+ isNSFWHiddenForUser (user: User, serverConfig: HTMLServerConfig) {
return isVideoNSFWHiddenForUser(this, serverConfig, user)
}
+ isNSFWHiddenOrWarned (user: User, serverConfig: HTMLServerConfig) {
+ return this.isNSFWHiddenForUser(user, serverConfig) || this.isNSFWWarnedForUser(user, serverConfig)
+ }
+
+ // ---------------------------------------------------------------------------
+
isRemovableBy (user: AuthUser) {
return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.REMOVE_ANY_VIDEO))
}
diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
index 69aca6a7f1..a03c3f0c5d 100644
--- a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
+++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
@@ -300,11 +300,11 @@ export class VideoMiniatureComponent implements OnInit {
// ---------------------------------------------------------------------------
hasNSFWWarning () {
- return this.video().isVideoNSFWWarnedForUser(this.user(), this.serverConfig)
+ return this.video().isNSFWWarnedForUser(this.user(), this.serverConfig)
}
hasNSFWBlur () {
- return this.video().isVideoNSFWBlurForUser(this.user(), this.serverConfig)
+ return this.video().isNSFWBlurForUser(this.user(), this.serverConfig)
}
// ---------------------------------------------------------------------------
diff --git a/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts b/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts
index 8dee8a49e2..506d602972 100644
--- a/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts
+++ b/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts
@@ -126,11 +126,11 @@ export class VideoPlaylistElementMiniatureComponent implements OnInit {
}
hasNSFWBlur (video: Video) {
- return video.isVideoNSFWBlurForUser(this.user, this.serverConfig)
+ return video.isNSFWBlurForUser(this.user, this.serverConfig)
}
hasNSFWWarning (video: Video) {
- return video.isVideoNSFWWarnedForUser(this.user, this.serverConfig)
+ return video.isNSFWWarnedForUser(this.user, this.serverConfig)
}
getNSFWTooltip (video: Video) {