aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r--server/models/video/video.ts24
1 files changed, 21 insertions, 3 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 164122ee2..1f3c25ecb 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1196,9 +1196,15 @@ export class VideoModel extends Model<VideoModel> {
1196 }) 1196 })
1197 } 1197 }
1198 1198
1199 static listUserVideosForApi (accountId: number, start: number, count: number, sort: string) { 1199 static listUserVideosForApi (
1200 accountId: number,
1201 start: number,
1202 count: number,
1203 sort: string,
1204 search?: string
1205 ) {
1200 function buildBaseQuery (): FindOptions { 1206 function buildBaseQuery (): FindOptions {
1201 return { 1207 let baseQuery = {
1202 offset: start, 1208 offset: start,
1203 limit: count, 1209 limit: count,
1204 order: getVideoSort(sort), 1210 order: getVideoSort(sort),
@@ -1218,12 +1224,24 @@ export class VideoModel extends Model<VideoModel> {
1218 } 1224 }
1219 ] 1225 ]
1220 } 1226 }
1227
1228 if (search) {
1229 baseQuery = Object.assign(baseQuery, {
1230 where: {
1231 name: {
1232 [ Op.iLike ]: '%' + search + '%'
1233 }
1234 }
1235 })
1236 }
1237
1238 return baseQuery
1221 } 1239 }
1222 1240
1223 const countQuery = buildBaseQuery() 1241 const countQuery = buildBaseQuery()
1224 const findQuery = buildBaseQuery() 1242 const findQuery = buildBaseQuery()
1225 1243
1226 const findScopes = [ 1244 const findScopes: (string | ScopeOptions)[] = [
1227 ScopeNames.WITH_SCHEDULED_UPDATE, 1245 ScopeNames.WITH_SCHEDULED_UPDATE,
1228 ScopeNames.WITH_BLACKLISTED, 1246 ScopeNames.WITH_BLACKLISTED,
1229 ScopeNames.WITH_THUMBNAILS 1247 ScopeNames.WITH_THUMBNAILS