Skip to content

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

Display blocked information in video manage

Chocobozzz54e644b83966
diff --git a/client/src/app/+video-watch/shared/information/video-alert.component.html b/client/src/app/+video-watch/shared/information/video-alert.component.html
index 35ee3b339b..665f827a8d 100644
--- a/client/src/app/+video-watch/shared/information/video-alert.component.html
+++ b/client/src/app/+video-watch/shared/information/video-alert.component.html
@@ -24,26 +24,29 @@
@if (getAlertWarning()?.title) {
<my-alert type="warning">
<div class="alert-title">{{ getAlertWarning()?.title }}</div>
- @if (canSeeMoreInfo()) {
+
+ @if (canSeeMoreStateInfo()) {
{{ getAlertWarning().watchSecondary }}
}
+
{{ getAlertWarning().watchMain }}
</my-alert>
}
+@if (getAlertError()?.title) {
+ <my-alert type="danger">
+ <div class="alert-title">{{ getAlertError()?.title }}</div>
+
+ {{ getAlertError().main }}
+ </my-alert>
+}
+
@if (noPlaylistVideoFound()) {
<my-alert i18n type="warning">
There are no videos available in this playlist.
</my-alert>
}
-@if (video()?.blacklisted) {
- <my-alert type="danger">
- <div class="blocked-label" i18n>This video is blocked.</div>
- {{ video().blacklistedReason }}
- </my-alert>
-}
-
@if (video()?.canBypassPassword(user())) {
<my-alert i18n type="warning">
This video is password protected.
diff --git a/client/src/app/+video-watch/shared/information/video-alert.component.ts b/client/src/app/+video-watch/shared/information/video-alert.component.ts
index 7069b6b16a..74e73b8f09 100644
--- a/client/src/app/+video-watch/shared/information/video-alert.component.ts
+++ b/client/src/app/+video-watch/shared/information/video-alert.component.ts
@@ -19,7 +19,7 @@ export class VideoAlertComponent {
private readonly videoStateMessage = inject(VideoStateMessageService)
- canSeeMoreInfo () {
+ canSeeMoreStateInfo () {
return !!(this.user()?.hasRight(UserRight.UPDATE_ANY_VIDEO))
}
@@ -27,7 +27,18 @@ export class VideoAlertComponent {
const video = this.video()
if (!video) return undefined
- return this.videoStateMessage.buildWarn(video.id, video.state.id)
+ return this.videoStateMessage.buildWarn({ videoId: video.id, state: video.state.id })
+ }
+
+ getAlertError () {
+ const video = this.video()
+ if (!video) return undefined
+
+ return this.videoStateMessage.buildErr({
+ videoId: video.id,
+ blacklisted: video.blacklisted,
+ blacklistedReason: video.blacklistedReason
+ })
}
hasVideoScheduledPublication () {
diff --git a/client/src/app/+videos-publish-manage/shared-manage/common/video-edit.model.ts b/client/src/app/+videos-publish-manage/shared-manage/common/video-edit.model.ts
index 5dba7f7abc..0112b04410 100644
--- a/client/src/app/+videos-publish-manage/shared-manage/common/video-edit.model.ts
+++ b/client/src/app/+videos-publish-manage/shared-manage/common/video-edit.model.ts
@@ -112,6 +112,7 @@ type UpdateFromAPIOptions = {
| 'aspectRatio'
| 'views'
| 'blacklisted'
+ | 'blacklistedReason'
| 'thumbnails'
| 'state'
| 'isLive'
@@ -165,6 +166,7 @@ export class VideoEdit {
duration: number
likes: number
blacklisted: boolean
+ blacklistedReason: string
ownerAccountId: number
ownerAccountDisplayName: string
@@ -187,6 +189,7 @@ export class VideoEdit {
likes: number
blacklisted: boolean
+ blacklistedReason: string
ownerAccountId: number
ownerAccountDisplayName: string
@@ -414,6 +417,7 @@ export class VideoEdit {
this.metadata.likes = video.likes
this.metadata.aspectRatio = video.aspectRatio
this.metadata.blacklisted = video.blacklisted
+ this.metadata.blacklistedReason = video.blacklistedReason
this.metadata.isLive = video.isLive
@@ -1047,6 +1051,7 @@ export class VideoEdit {
likes: this.metadata.likes,
duration: this.metadata.duration,
blacklisted: this.metadata.blacklisted,
+ blacklistedReason: this.metadata.blacklistedReason,
ownerAccountId: this.metadata.ownerAccountId,
ownerAccountDisplayName: this.metadata.ownerAccountDisplayName,
diff --git a/client/src/app/+videos-publish-manage/shared-manage/live-settings/live-stream-information.component.ts b/client/src/app/+videos-publish-manage/shared-manage/live-settings/live-stream-information.component.ts
index 8de99dc9fc..5beee845b0 100644
--- a/client/src/app/+videos-publish-manage/shared-manage/live-settings/live-stream-information.component.ts
+++ b/client/src/app/+videos-publish-manage/shared-manage/live-settings/live-stream-information.component.ts
@@ -35,7 +35,7 @@ export class LiveStreamInformationComponent implements OnInit {
const errors: { [id in LiveVideoErrorType]: string } = {
[LiveVideoError.BAD_SOCKET_HEALTH]: $localize`Server too slow`,
- [LiveVideoError.BLACKLISTED]: $localize`Live blacklisted`,
+ [LiveVideoError.BLACKLISTED]: $localize`Live blocked by the platform`,
[LiveVideoError.DURATION_EXCEEDED]: $localize`Max duration exceeded`,
[LiveVideoError.FFMPEG_ERROR]: $localize`Server error`,
[LiveVideoError.QUOTA_EXCEEDED]: $localize`Quota exceeded`,
diff --git a/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.html b/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.html
index cb69138058..d3a5cf4d20 100644
--- a/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.html
+++ b/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.html
@@ -37,15 +37,22 @@
</div>
</div>
- @if (getStateWarning()?.title) {
- <div class="video-state video-header-block mt-2">
- <div class="alert-title">{{ getStateWarning().title }}</div>
- <strong class="me-1">{{ getStateWarning().manageMain }}</strong>
- <span>{{ getStateWarning().manageSecondary }}</span>
+ @if (getVideoError()?.title) {
+ <div class="video-alert video-err alert alert-danger mt-2" role="alert">
+ <div class="alert-title">{{ getVideoError().title }}</div>
+ <div class="me-1">{{ getVideoError().main }}</div>
+ </div>
+ }
+
+ @if (getVideoWarning()?.title) {
+ <div class="video-alert video-warn mt-2" role="alert">
+ <div class="alert-title">{{ getVideoWarning().title }}</div>
+ <strong class="me-1">{{ getVideoWarning().manageMain }}</strong>
+ <span>{{ getVideoWarning().manageSecondary }}</span>
- @if (getStateWarning().routerLink) {
+ @if (getVideoWarning().routerLink) {
<span class="ms-1">
- <a [routerLink]="getStateWarning().routerLink.link" [queryParams]="getStateWarning().routerLink.queryParams">{{ getStateWarning().routerLink.text }}</a>
+ <a [routerLink]="getVideoWarning().routerLink.link" [queryParams]="getVideoWarning().routerLink.queryParams">{{ getVideoWarning().routerLink.text }}</a>
</span>
}
</div>
diff --git a/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.scss b/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.scss
index 15e4925cc0..ea74eb27fa 100644
--- a/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.scss
+++ b/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.scss
@@ -12,11 +12,30 @@
}
}
-.video-header-block {
+.video-header-block,
+.video-alert {
border-radius: 14px;
+}
+
+.video-header-block,
+.video-warn {
background-color: pvar(--bg-secondary-350);
}
+.video-warn {
+ color: pvar(--fg-300);
+}
+
+.video-err {
+ border: 0;
+}
+
+.video-alert {
+ padding: 1rem 1.5rem;
+
+ @include font-size(14px);
+}
+
.video-actions-container {
position: sticky;
top: pvar(--header-height);
@@ -71,10 +90,3 @@
gap: 0.5rem;
}
}
-
-.video-state {
- color: pvar(--fg-300);
- padding: 1rem 1.5rem;
-
- @include font-size(14px);
-}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.ts b/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.ts
index d77007df46..94a51c9a61 100644
--- a/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.ts
+++ b/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.ts
@@ -4,6 +4,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { RouterModule } from '@angular/router'
import { Notifier, ScreenService } from '@app/core'
import { HeaderService } from '@app/header/header.service'
+import { AlertComponent } from '@app/shared/shared-main/common/alert.component'
import { Video } from '@app/shared/shared-main/video/video.model'
import { VideoStateMessageService } from '@app/shared/shared-video/video-state-message.service'
import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap'
@@ -26,7 +27,8 @@ import { VideoManageMenuComponent } from './video-manage-menu.component'
ManageErrorsComponent,
NgbTooltipModule,
UploadProgressComponent,
- VideoManageMenuComponent
+ VideoManageMenuComponent,
+ AlertComponent
]
})
export class VideoManageContainerComponent implements OnInit, OnDestroy {
@@ -73,10 +75,20 @@ export class VideoManageContainerComponent implements OnInit, OnDestroy {
// ---------------------------------------------------------------------------
- getStateWarning () {
+ getVideoWarning () {
const video = this.videoEdit.getVideoAttributes()
- return this.videoStateMessage.buildWarn(video.id, video.state)
+ return this.videoStateMessage.buildWarn({ videoId: video.id, state: video.state })
+ }
+
+ getVideoError () {
+ const video = this.videoEdit.getVideoAttributes()
+
+ return this.videoStateMessage.buildErr({
+ videoId: video.id,
+ blacklisted: video.blacklisted,
+ blacklistedReason: video.blacklistedReason
+ })
}
// ---------------------------------------------------------------------------
diff --git a/client/src/app/shared/shared-video/video-state-message.service.ts b/client/src/app/shared/shared-video/video-state-message.service.ts
index 9315885f15..13b4dda205 100644
--- a/client/src/app/shared/shared-video/video-state-message.service.ts
+++ b/client/src/app/shared/shared-video/video-state-message.service.ts
@@ -1,10 +1,13 @@
import { Injectable } from '@angular/core'
+import { generateNaiveHash } from '@peertube/peertube-core-utils'
import { VideoState, VideoStateType } from '@peertube/peertube-models'
-type WarnResult = {
+type WarnMessageResult = {
title: string
+
manageMain: string
manageSecondary: string
+
watchMain: string
watchSecondary: string
@@ -15,22 +18,40 @@ type WarnResult = {
}
}
+type ErrMessageResult = {
+ title: string
+ main: string
+}
+
@Injectable()
export class VideoStateMessageService {
- private cacheKey: string
- private cacheResult: WarnResult
+ private warnCacheKey: string
+ private warnCacheResult: WarnMessageResult
+
+ private errCacheKey: string
+ private errCacheResult: ErrMessageResult
+
+ buildWarn (options: {
+ videoId: number
+ state: VideoStateType
+ }): WarnMessageResult {
+ const { videoId, state } = options
- buildWarn (videoId: number, state: VideoStateType): WarnResult {
const key = `${videoId}-${state}`
- if (this.cacheKey === key && this.cacheResult) return this.cacheResult
+ if (this.warnCacheKey === key && this.warnCacheResult) return this.warnCacheResult
- this.cacheResult = this._buildWarn(videoId, state)
- this.cacheKey = key
+ this.warnCacheResult = this._buildWarn(options)
+ this.warnCacheKey = key
- return this.cacheResult
+ return this.warnCacheResult
}
- private _buildWarn (videoId: number, state: VideoStateType): WarnResult {
+ private _buildWarn (options: {
+ videoId: number
+ state: VideoStateType
+ }): WarnMessageResult {
+ const { videoId, state } = options
+
const manageProcessed = $localize`Your video file is being processed.`
const manageFeaturesDisabled = $localize`This can take a while and some features may not be available until it is complete.`
const manageContactAdmin = $localize`Contact your administrator to fix it.`
@@ -146,4 +167,36 @@ export class VideoStateMessageService {
return state satisfies never
}
}
+
+ // ---------------------------------------------------------------------------
+
+ buildErr (options: {
+ videoId: number
+ blacklisted: boolean
+ blacklistedReason: string
+ }): ErrMessageResult {
+ const { videoId, blacklisted, blacklistedReason } = options
+
+ const key = `${videoId}-${blacklisted}-${generateNaiveHash(blacklistedReason)}`
+ if (this.errCacheKey === key && this.errCacheResult) return this.errCacheResult
+
+ this.errCacheResult = this._buildErr(options)
+ this.errCacheKey = key
+
+ return this.errCacheResult
+ }
+
+ private _buildErr (options: {
+ blacklisted: boolean
+ blacklistedReason: string
+ }): ErrMessageResult {
+ const { blacklisted, blacklistedReason } = options
+
+ if (!blacklisted) return undefined
+
+ return {
+ title: $localize`Blocked video`,
+ main: blacklistedReason || $localize`Your video has been blocked by the platform`
+ }
+ }
}
diff --git a/packages/core-utils/src/string/hash.ts b/packages/core-utils/src/string/hash.ts
new file mode 100644
index 0000000000..1bb3fced8d
--- /dev/null
+++ b/packages/core-utils/src/string/hash.ts
@@ -0,0 +1,12 @@
+// https://stackoverflow.com/a/7616484
+export function generateNaiveHash (str: string) {
+ let hash = 0
+
+ if (!str) return hash
+
+ for (const char of str) {
+ hash = (hash << 5) - hash + char.charCodeAt(0)
+ hash |= 0 // Constrain to 32bit integer
+ }
+ return hash
+}
diff --git a/packages/core-utils/src/string/index.ts b/packages/core-utils/src/string/index.ts
index 42680ab165..1491d39f41 100644
--- a/packages/core-utils/src/string/index.ts
+++ b/packages/core-utils/src/string/index.ts
@@ -1 +1,2 @@
export * from './chapters.js'
+export * from './hash.js'
diff --git a/server/core/lib/video-blacklist.ts b/server/core/lib/video-blacklist.ts
index ba30550c80..073cfed452 100644
--- a/server/core/lib/video-blacklist.ts
+++ b/server/core/lib/video-blacklist.ts
@@ -43,7 +43,7 @@ export async function autoBlacklistVideoIfNeeded (parameters: {
const videoBlacklistToCreate = {
videoId: video.id,
unfederated: true,
- reason: t('Automatically blocked. Moderator review is required.', user?.getLanguage() ?? englishLanguage),
+ reason: t('The video has been automatically blocked. A moderator review is required.', user?.getLanguage() ?? englishLanguage),
type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED
}
const [ videoBlacklist ] = await VideoBlacklistModel.findOrCreate<MVideoBlacklistVideo>({