Skip to content

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

Add video block bulk actions

Chocobozzz1be641d16d86
diff --git a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.html b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.html
index ce103e9c99..2edbf7fc8e 100644
--- a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.html
+++ b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.html
@@ -7,6 +7,7 @@
[dataLoader]="dataLoader"
columnConfig="false"
[inputFilters]="inputFilters"
+ [bulkActions]="bulkActions"
searchInput="true"
>
<ng-template #totalTitle let-totalRecords>
@@ -24,6 +25,10 @@
</my-video-cell>
</td>
+ <td>
+ <my-privacy-badge [video]="videoBlock.video"></my-privacy-badge>
+ </td>
+
<td>
<my-video-nsfw-badge [video]="videoBlock.video" theme="red"></my-video-nsfw-badge>
</td>
diff --git a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts
index 2e6051e8a0..26fc175420 100644
--- a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts
+++ b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts
@@ -1,8 +1,10 @@
import { Component, OnInit, inject, viewChild } from '@angular/core'
import { ConfirmService, MarkdownService, Notifier, ServerService } from '@app/core'
+import { formatICU } from '@app/helpers'
import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'
import { VideoService } from '@app/shared/shared-main/video/video.service'
import { VideoBlockService } from '@app/shared/shared-moderation/video-block.service'
+import { PrivacyBadgeComponent } from '@app/shared/shared-video/privacy-badge.component'
import { buildVideoEmbedLink, decorateVideoLink } from '@peertube/peertube-core-utils'
import { ResultList, VideoBlacklist as VideoBlacklistServer, VideoBlacklistType, VideoBlacklistType_Type } from '@peertube/peertube-models'
import { buildVideoOrPlaylistEmbed } from '@root-helpers/video'
@@ -30,7 +32,8 @@ type VideoBlacklist = VideoBlacklistServer & { reasonHtml?: string }
PTDatePipe,
VideoNSFWBadgeComponent,
TableComponent,
- NumberFormatterPipe
+ NumberFormatterPipe,
+ PrivacyBadgeComponent
]
})
export class VideoBlockListComponent implements OnInit {
@@ -46,6 +49,7 @@ export class VideoBlockListComponent implements OnInit {
blocklistTypeFilter: VideoBlacklistType_Type
videoBlocklistActions: DropdownAction<VideoBlacklist>[][] = []
+ bulkActions: DropdownAction<VideoBlacklist[]>[][] = []
inputFilters: AdvancedFilterDef<DataLoaderParameter>[] = [
{
@@ -62,6 +66,7 @@ export class VideoBlockListComponent implements OnInit {
columns: TableColumnInfo<string>[] = [
{ id: 'name', label: $localize`Video`, sortable: true },
+ { id: 'privacy', label: $localize`Privacy`, sortable: false },
{ id: 'sensitive', label: $localize`Sensitive`, sortable: false },
{ id: 'unfederated', label: $localize`Unfederated`, sortable: false },
{ id: 'createdAt', label: $localize`Date`, sortable: true }
@@ -81,18 +86,7 @@ export class VideoBlockListComponent implements OnInit {
},
{
label: $localize`Switch video block to manual`,
- handler: videoBlock => {
- this.videoBlocklistService.unblockVideo(videoBlock.video.id).pipe(
- switchMap(_ => this.videoBlocklistService.blockVideo([ { videoId: videoBlock.video.id, unfederate: true } ]))
- ).subscribe({
- next: () => {
- this.notifier.success($localize`Video ${videoBlock.video.name} switched to manual block.`)
- this.table().loadData()
- },
-
- error: err => this.notifier.handleError(err)
- })
- },
+ handler: videoBlock => this.switchVideosBlockToManual([ videoBlock ]),
isDisplayed: videoBlock => videoBlock.type === VideoBlacklistType.AUTO_BEFORE_PUBLISHED
}
],
@@ -103,28 +97,41 @@ export class VideoBlockListComponent implements OnInit {
},
{
label: $localize`Unblock`,
- handler: videoBlock => this.unblockVideo(videoBlock)
+ handler: videoBlock => this.unblockVideos([ videoBlock ])
},
{
- label: $localize`Delete`,
- handler: async videoBlock => {
- const res = await this.confirmService.confirm(
- $localize`Do you really want to delete this video?`,
- $localize`Delete`
- )
- if (res === false) return
-
- this.videoService.removeVideo(videoBlock.video.id)
- .subscribe({
- next: () => {
- this.notifier.success($localize`Video deleted.`)
- this.table().loadData()
- },
+ label: $localize`Delete video`,
+ handler: videoBlock => this.deleteVideos([ videoBlock ])
+ }
+ ]
+ ]
- error: err => this.notifier.handleError(err)
- })
- }
+ this.bulkActions = [
+ [
+ {
+ label: $localize`Internal actions`,
+ isHeader: true,
+ isDisplayed: entries => entries.every(entry => entry.type === VideoBlacklistType.AUTO_BEFORE_PUBLISHED)
+ },
+ {
+ label: $localize`Switch videos block to manual`,
+ handler: entries => this.switchVideosBlockToManual(entries),
+ isDisplayed: entries => entries.every(entry => entry.type === VideoBlacklistType.AUTO_BEFORE_PUBLISHED)
+ }
+ ],
+ [
+ {
+ label: $localize`Actions for videos`,
+ isHeader: true
+ },
+ {
+ label: $localize`Unblock`,
+ handler: entries => this.unblockVideos(entries)
+ },
+ {
+ label: $localize`Delete video`,
+ handler: entries => this.deleteVideos(entries)
}
]
]
@@ -149,7 +156,7 @@ export class VideoBlockListComponent implements OnInit {
const res = await this.confirmService.confirm(confirmMessage, $localize`Unblock`)
if (res === false) return
- this.videoBlocklistService.unblockVideo(entry.video.id)
+ this.videoBlocklistService.unblockVideos([ entry.video.id ])
.subscribe({
next: () => {
this.notifier.success($localize`Video ${entry.video.name} unblocked.`)
@@ -160,6 +167,86 @@ export class VideoBlockListComponent implements OnInit {
})
}
+ async unblockVideos (entries: VideoBlacklist[]) {
+ const confirmMessage = formatICU(
+ $localize`Do you really want to unblock {count, plural, =1 {this video?} other {these {count} videos?}}`,
+ { count: entries.length }
+ )
+
+ const res = await this.confirmService.confirm(confirmMessage, $localize`Unblock`)
+ if (res === false) return
+
+ this.videoBlocklistService.unblockVideos(entries.map(entry => entry.video.id))
+ .subscribe({
+ next: () => {
+ this.notifier.success(
+ formatICU(
+ $localize`{count, plural, =1 {Video unblocked.} other {{count} videos unblocked.}}`,
+ { count: entries.length }
+ )
+ )
+ this.table().loadData()
+ },
+
+ error: err => this.notifier.handleError(err)
+ })
+ }
+
+ async switchVideosBlockToManual (entries: VideoBlacklist[]) {
+ const res = await this.confirmService.confirm(
+ formatICU(
+ $localize`Switch {count, plural, =1 {this auto block to manual?} other {{count} auto blocks to manual?}}`,
+ { count: entries.length }
+ ),
+ $localize`Switch`
+ )
+ if (res === false) return
+
+ const videoIds = entries.map(entry => entry.video.id)
+
+ this.videoBlocklistService.unblockVideos(videoIds).pipe(
+ switchMap(() => this.videoBlocklistService.blockVideos(videoIds.map(videoId => ({ videoId, unfederate: true }))))
+ ).subscribe({
+ next: () => {
+ this.notifier.success(
+ formatICU(
+ $localize`{count, plural, =1 {Video switched to manual block.} other {{count} videos switched to manual block.}}`,
+ { count: entries.length }
+ )
+ )
+ this.table().loadData()
+ },
+
+ error: err => this.notifier.handleError(err)
+ })
+ }
+
+ async deleteVideos (entries: VideoBlacklist[]) {
+ const res = await this.confirmService.confirm(
+ formatICU(
+ $localize`Do you really want to delete {count, plural, =1 {this video?} other {{count} videos?}}`,
+ { count: entries.length }
+ ),
+ $localize`Delete`
+ )
+ if (res === false) return
+
+ this.videoService.removeVideo(entries.map(entry => entry.video.id))
+ .subscribe({
+ next: () => {
+ this.notifier.success(
+ formatICU(
+ $localize`{count, plural, =1 {Video deleted.} other {{count} videos deleted.}}`,
+ { count: entries.length }
+ )
+ )
+ this.table().loadData()
+ },
+
+ error: err => this.notifier.handleError(err)
+ })
+ }
+
getVideoEmbed (entry: VideoBlacklist) {
return buildVideoOrPlaylistEmbed({
embedUrl: decorateVideoLink({
diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.ts
index 0b96869456..3af61dd301 100644
--- a/client/src/app/+admin/overview/videos/video-list.component.ts
+++ b/client/src/app/+admin/overview/videos/video-list.component.ts
@@ -405,7 +405,7 @@ export class VideoListComponent implements OnInit {
}
private unblockVideos (videos: Video[]) {
- this.videoBlockService.unblockVideo(videos.map(v => v.id))
+ this.videoBlockService.unblockVideos(videos.map(v => v.id))
.subscribe({
next: () => {
this.notifier.success(
diff --git a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
index 064c8472f0..ace7543e9f 100644
--- a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
+++ b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
@@ -412,7 +412,7 @@ export class AbuseListTableComponent implements OnInit, OnDestroy {
label: $localize`Block video`,
isDisplayed: abuse => abuse.video && !abuse.video.deleted && !abuse.video.blacklisted,
handler: abuse => {
- this.videoBlocklistService.blockVideo([ { videoId: abuse.video.id, unfederate: abuse.video.channel.isLocal } ])
+ this.videoBlocklistService.blockVideos([ { videoId: abuse.video.id, unfederate: abuse.video.channel.isLocal } ])
.subscribe({
next: () => {
this.notifier.success($localize`Video blocked.`)
@@ -428,7 +428,7 @@ export class AbuseListTableComponent implements OnInit, OnDestroy {
label: $localize`Unblock video`,
isDisplayed: abuse => abuse.video && !abuse.video.deleted && abuse.video.blacklisted,
handler: abuse => {
- this.videoBlocklistService.unblockVideo(abuse.video.id)
+ this.videoBlocklistService.unblockVideos(abuse.video.id)
.subscribe({
next: () => {
this.notifier.success($localize`Video unblocked.`)
diff --git a/client/src/app/shared/shared-moderation/video-block.component.ts b/client/src/app/shared/shared-moderation/video-block.component.ts
index d2a0ddbcd0..3619e3d4fe 100644
--- a/client/src/app/shared/shared-moderation/video-block.component.ts
+++ b/client/src/app/shared/shared-moderation/video-block.component.ts
@@ -79,7 +79,7 @@ export class VideoBlockComponent extends FormReactive implements OnInit {
: undefined
}))
- this.videoBlocklistService.blockVideo(options)
+ this.videoBlocklistService.blockVideos(options)
.subscribe({
next: () => {
const message = formatICU(
diff --git a/client/src/app/shared/shared-moderation/video-block.service.ts b/client/src/app/shared/shared-moderation/video-block.service.ts
index 85a78c9887..5128eeddea 100644
--- a/client/src/app/shared/shared-moderation/video-block.service.ts
+++ b/client/src/app/shared/shared-moderation/video-block.service.ts
@@ -34,7 +34,7 @@ export class VideoBlockService {
.pipe(catchError(res => this.restExtractor.handleError(res)))
}
- unblockVideo (videoIdArgs: number | number[]) {
+ unblockVideos (videoIdArgs: number | number[]) {
const videoIds = arrayify(videoIdArgs)
return observableFrom(videoIds)
@@ -45,7 +45,7 @@ export class VideoBlockService {
)
}
- blockVideo (options: {
+ blockVideos (options: {
videoId: number
reason?: string
unfederate: boolean
diff --git a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts
index 7947257cf8..2ff657c169 100644
--- a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts
+++ b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts
@@ -284,7 +284,7 @@ export class VideoActionsDropdownComponent implements OnChanges {
const res = await this.confirmService.confirm(confirmMessage, $localize`Unblock ${this.video().name}`)
if (res === false) return
- this.videoBlocklistService.unblockVideo(this.video().id)
+ this.videoBlocklistService.unblockVideos(this.video().id)
.subscribe({
next: () => {
const video = this.video()
diff --git a/packages/tests/src/api/moderation/video-blacklist.ts b/packages/tests/src/api/moderation/video-blacklist.ts
index ec020b0e03..d40ae0c927 100644
--- a/packages/tests/src/api/moderation/video-blacklist.ts
+++ b/packages/tests/src/api/moderation/video-blacklist.ts
@@ -6,7 +6,8 @@ import {
BlacklistCommand,
cleanupTests,
createMultipleServers,
- doubleFollow, makeActivityPubGetRequest,
+ doubleFollow,
+ makeActivityPubGetRequest,
PeerTubeServer,
setAccessTokensToServers,
setDefaultChannelAvatar,
@@ -55,7 +56,6 @@ describe('Test video blacklist', function () {
})
describe('When listing/searching videos', function () {
-
it('Should not have the video blacklisted in videos list/search on server 1', async function () {
{
const { total, data } = await servers[0].videos.list()
@@ -94,7 +94,6 @@ describe('Test video blacklist', function () {
})
describe('When listing manually blacklisted videos', function () {
-
it('Should display all the blacklisted videos', async function () {
const body = await command.list()
expect(body.total).to.equal(2)
@@ -165,7 +164,6 @@ describe('Test video blacklist', function () {
})
describe('When updating blacklisted videos', function () {
-
it('Should change the reason', async function () {
await command.update({ videoId, reason: 'my super reason updated' })
@@ -319,6 +317,10 @@ describe('Test video blacklist', function () {
}
})
+ it('Should not crash when unfederating an internal blacklisted video', async function () {
+ const video = await servers[0].videos.quickUpload({ name: 'internal video', privacy: VideoPrivacy.INTERNAL })
+ await command.add({ videoId: video.uuid, reason: 'super reason', unfederate: true })
+ })
})
describe('When auto blacklist videos', function () {
diff --git a/server/core/lib/video-blacklist.ts b/server/core/lib/video-blacklist.ts
index 74ada34939..b021b2b629 100644
--- a/server/core/lib/video-blacklist.ts
+++ b/server/core/lib/video-blacklist.ts
@@ -17,7 +17,7 @@ import { logger, loggerTagsFactory } from '../helpers/logger.js'
import { CONFIG } from '../initializers/config.js'
import { VideoBlacklistModel } from '../models/video/video-blacklist.js'
import { sendDeleteVideo } from './activitypub/send/index.js'
-import { federateVideoIfNeeded } from './activitypub/videos/index.js'
+import { federateVideoIfNeeded, isPrivacyForFederation } from './activitypub/videos/index.js'
import { LiveManager } from './live/live-manager.js'
import { Notifier } from './notifier/index.js'
import { Hooks } from './plugins/hooks.js'
@@ -79,7 +79,7 @@ export async function blacklistVideo (videoInstance: MVideoAccountLight, options
})
blacklist.Video = videoInstance
- if (options.unfederate === true) {
+ if (options.unfederate === true && videoInstance.isLocal() && isPrivacyForFederation(videoInstance.privacy)) {
await sendDeleteVideo({ video: videoInstance, transaction: undefined })
}