]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
Add ability to bulk block videos
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-abuse-list / abuse-list-table.component.ts
index 33e9fd8de7d5e494d0cf77ed28877337afeab2e2..08cf297ccfa4c091c9287a85d50abcc8b714acba 100644 (file)
@@ -1,8 +1,6 @@
 import * as debug from 'debug'
 import truncate from 'lodash-es/truncate'
 import { SortMeta } from 'primeng/api'
-import { buildVideoOrPlaylistEmbed } from 'src/assets/player/utils'
-import { environment } from 'src/environments/environment'
 import { Component, Input, OnInit, ViewChild } from '@angular/core'
 import { DomSanitizer } from '@angular/platform-browser'
 import { ActivatedRoute, Router } from '@angular/router'
@@ -10,7 +8,6 @@ import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable }
 import { Account, Actor, DropdownAction, Video, VideoService } from '@app/shared/shared-main'
 import { AbuseService, BlocklistService, VideoBlockService } from '@app/shared/shared-moderation'
 import { VideoCommentService } from '@app/shared/shared-video-comment'
-import { buildVideoEmbedLink, decorateVideoLink } from '@shared/core-utils'
 import { AbuseState, AdminAbuse } from '@shared/models'
 import { AdvancedInputFilter } from '../shared-forms'
 import { AbuseMessageModalComponent } from './abuse-message-modal.component'
@@ -39,24 +36,29 @@ export class AbuseListTableComponent extends RestTable implements OnInit {
 
   inputFilters: AdvancedInputFilter[] = [
     {
-      queryParams: { search: 'state:pending' },
-      label: $localize`Unsolved reports`
-    },
-    {
-      queryParams: { search: 'state:accepted' },
-      label: $localize`Accepted reports`
-    },
-    {
-      queryParams: { search: 'state:rejected' },
-      label: $localize`Refused reports`
-    },
-    {
-      queryParams: { search: 'videoIs:blacklisted' },
-      label: $localize`Reports with blocked videos`
-    },
-    {
-      queryParams: { search: 'videoIs:deleted' },
-      label: $localize`Reports with deleted videos`
+      title: $localize`Advanced filters`,
+      children: [
+        {
+          value: 'state:pending',
+          label: $localize`Unsolved reports`
+        },
+        {
+          value: 'state:accepted',
+          label: $localize`Accepted reports`
+        },
+        {
+          value: 'state:rejected',
+          label: $localize`Refused reports`
+        },
+        {
+          value: 'videoIs:blacklisted',
+          label: $localize`Reports with blocked videos`
+        },
+        {
+          value: 'videoIs:deleted',
+          label: $localize`Reports with deleted videos`
+        }
+      ]
     }
   ]
 
@@ -128,19 +130,6 @@ export class AbuseListTableComponent extends RestTable implements OnInit {
     return '/a/' + abuse.flaggedAccount.nameWithHost
   }
 
-  getVideoEmbed (abuse: AdminAbuse) {
-    return buildVideoOrPlaylistEmbed(
-      decorateVideoLink({
-        url: buildVideoEmbedLink(abuse.video, environment.originServerUrl),
-        title: false,
-        warningTitle: false,
-        startTime: abuse.video.startAt,
-        stopTime: abuse.video.endAt
-      }),
-      abuse.video.name
-    )
-  }
-
   async removeAbuse (abuse: AdminAbuse) {
     const res = await this.confirmService.confirm($localize`Do you really want to delete this abuse report?`, $localize`Delete`)
     if (res === false) return
@@ -215,8 +204,6 @@ export class AbuseListTableComponent extends RestTable implements OnInit {
           }
 
           if (abuse.video) {
-            abuse.embedHtml = this.sanitizer.bypassSecurityTrustHtml(this.getVideoEmbed(abuse))
-
             if (abuse.video.channel?.ownerAccount) {
               abuse.video.channel.ownerAccount = new Account(abuse.video.channel.ownerAccount)
             }
@@ -351,7 +338,7 @@ export class AbuseListTableComponent extends RestTable implements OnInit {
         label: $localize`Block video`,
         isDisplayed: abuse => abuse.video && !abuse.video.deleted && !abuse.video.blacklisted,
         handler: abuse => {
-          this.videoBlocklistService.blockVideo(abuse.video.id, undefined, abuse.video.channel.isLocal)
+          this.videoBlocklistService.blockVideo([ { videoId: abuse.video.id, unfederate: abuse.video.channel.isLocal } ])
             .subscribe({
               next: () => {
                 this.notifier.success($localize`Video blocked.`)