]> 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 9f1d03ac5e7f8f8744433db9cbf5d7c0f7e32499..71a5802499ea1007461d2420f9faad6e95cefd9e 100644 (file)
@@ -46,6 +46,8 @@ import { FindOptions, literal, Op, ScopeOptions, Transaction, WhereOptions } fro
 import * as Bluebird from 'bluebird'
 import {
   MVideoPlaylistAccountThumbnail,
+  MVideoPlaylistAP,
+  MVideoPlaylistFormattable,
   MVideoPlaylistFull,
   MVideoPlaylistFullSummary,
   MVideoPlaylistIdWithElements
@@ -66,7 +68,8 @@ type AvailableForListOptions = {
   type?: VideoPlaylistType
   accountId?: number
   videoChannelId?: number
-  privateAndUnlisted?: boolean
+  privateAndUnlisted?: boolean,
+  search?: string
 }
 
 @Scopes(() => ({
@@ -162,6 +165,14 @@ type AvailableForListOptions = {
       })
     }
 
+    if (options.search) {
+      whereAnd.push({
+        name: {
+          [ Op.iLike ]: '%' + options.search + '%'
+        }
+      })
+    }
+
     const where = {
       [Op.and]: whereAnd
     }
@@ -290,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,
@@ -307,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
         ]
       },
@@ -479,7 +492,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> {
     return isOutdated(this, ACTIVITY_PUB.VIDEO_PLAYLIST_REFRESH_INTERVAL)
   }
 
-  toFormattedJSON (): VideoPlaylist {
+  toFormattedJSON (this: MVideoPlaylistFormattable): VideoPlaylist {
     return {
       id: this.id,
       uuid: this.uuid,
@@ -509,7 +522,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> {
     }
   }
 
-  toActivityPubObject (page: number, t: Transaction): Promise<PlaylistObject> {
+  toActivityPubObject (this: MVideoPlaylistAP, page: number, t: Transaction): Promise<PlaylistObject> {
     const handler = (start: number, count: number) => {
       return VideoPlaylistElementModel.listUrlsOfForAP(this.id, start, count, t)
     }