]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-abuse.ts
Support is:blacklisted as video-abuse-list filter
[github/Chocobozzz/PeerTube.git] / server / models / video / video-abuse.ts
index b1f8fed90e8545dddaccaa075075642520cb81a2..f6b5468251d826429c67f0d950a0d665a849aa8f 100644 (file)
@@ -90,10 +90,13 @@ export enum ScopeNames {
       })
     }
 
-    if (options.is) {
+    let onlyBlacklisted = false
+    if (options.is === "deleted") {
       where = Object.assign(where, {
-        ...options.is
+        deletedVideo: { [Op.not]: null }
       })
+    } else if (options.is === "blacklisted") {
+      onlyBlacklisted = true
     }
 
     return {
@@ -184,7 +187,7 @@ export enum ScopeNames {
         },
         {
           model: VideoModel,
-          required: false,
+          required: onlyBlacklisted,
           where: searchAttribute(options.searchVideo, 'name'),
           include: [
             {
@@ -202,7 +205,8 @@ export enum ScopeNames {
             },
             {
               attributes: [ 'id', 'reason', 'unfederated' ],
-              model: VideoBlacklistModel
+              model: VideoBlacklistModel,
+              required: onlyBlacklisted
             }
           ]
         }
@@ -328,7 +332,8 @@ export class VideoAbuseModel extends Model<VideoAbuseModel> {
         is: {
           prefix: 'is:',
           handler: v => {
-            if (v === "deleted") return { deletedVideo: { [Op.not]: null } }
+            if (v === "deleted") return v
+            if (v === "blacklisted") return v
             return undefined
           }
         },