]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-playlist.ts
Add infohash cache
[github/Chocobozzz/PeerTube.git] / server / models / video / video-playlist.ts
index 278d80ac051d2144cd34be068256b3425f3d2e93..71a5802499ea1007461d2420f9faad6e95cefd9e 100644 (file)
@@ -45,7 +45,8 @@ import { ActivityIconObject } from '../../../shared/models/activitypub/objects'
 import { FindOptions, literal, Op, ScopeOptions, Transaction, WhereOptions } from 'sequelize'
 import * as Bluebird from 'bluebird'
 import {
-  MVideoPlaylistAccountThumbnail, MVideoPlaylistAP,
+  MVideoPlaylistAccountThumbnail,
+  MVideoPlaylistAP,
   MVideoPlaylistFormattable,
   MVideoPlaylistFull,
   MVideoPlaylistFullSummary,
@@ -67,7 +68,8 @@ type AvailableForListOptions = {
   type?: VideoPlaylistType
   accountId?: number
   videoChannelId?: number
-  privateAndUnlisted?: boolean
+  privateAndUnlisted?: boolean,
+  search?: string
 }
 
 @Scopes(() => ({
@@ -163,6 +165,14 @@ type AvailableForListOptions = {
       })
     }
 
+    if (options.search) {
+      whereAnd.push({
+        name: {
+          [ Op.iLike ]: '%' + options.search + '%'
+        }
+      })
+    }
+
     const where = {
       [Op.and]: whereAnd
     }
@@ -291,7 +301,8 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> {
     type?: VideoPlaylistType,
     accountId?: number,
     videoChannelId?: number,
-    privateAndUnlisted?: boolean
+    privateAndUnlisted?: boolean,
+    search?: string
   }) {
     const query = {
       offset: options.start,
@@ -308,7 +319,8 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> {
             followerActorId: options.followerActorId,
             accountId: options.accountId,
             videoChannelId: options.videoChannelId,
-            privateAndUnlisted: options.privateAndUnlisted
+            privateAndUnlisted: options.privateAndUnlisted,
+            search: options.search
           } as AvailableForListOptions
         ]
       },