aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/sql/videos-id-list-query-builder.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-28 16:40:21 +0200
committerChocobozzz <me@florianbigard.com>2021-07-28 16:40:21 +0200
commitfbd67e7f386504e50f2504cb6386700a58906f16 (patch)
tree1a7143aaea76ce4e195fb9d6214a0cd769c556ea /server/models/video/sql/videos-id-list-query-builder.ts
parent164c8d46cf5c948a28b4ac0e596fad9b83b2c229 (diff)
downloadPeerTube-fbd67e7f386504e50f2504cb6386700a58906f16.tar.gz
PeerTube-fbd67e7f386504e50f2504cb6386700a58906f16.tar.zst
PeerTube-fbd67e7f386504e50f2504cb6386700a58906f16.zip
Add ability to search by uuids/actor names
Diffstat (limited to 'server/models/video/sql/videos-id-list-query-builder.ts')
-rw-r--r--server/models/video/sql/videos-id-list-query-builder.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/server/models/video/sql/videos-id-list-query-builder.ts b/server/models/video/sql/videos-id-list-query-builder.ts
index d4260c69c..7625c003d 100644
--- a/server/models/video/sql/videos-id-list-query-builder.ts
+++ b/server/models/video/sql/videos-id-list-query-builder.ts
@@ -35,6 +35,8 @@ export type BuildVideosListQueryOptions = {
35 tagsOneOf?: string[] 35 tagsOneOf?: string[]
36 tagsAllOf?: string[] 36 tagsAllOf?: string[]
37 37
38 uuids?: string[]
39
38 withFiles?: boolean 40 withFiles?: boolean
39 41
40 accountId?: number 42 accountId?: number
@@ -161,6 +163,10 @@ export class VideosIdListQueryBuilder extends AbstractVideosQueryBuilder {
161 this.whereTagsAllOf(options.tagsAllOf) 163 this.whereTagsAllOf(options.tagsAllOf)
162 } 164 }
163 165
166 if (options.uuids) {
167 this.whereUUIDs(options.uuids)
168 }
169
164 if (options.nsfw === true) { 170 if (options.nsfw === true) {
165 this.whereNSFW() 171 this.whereNSFW()
166 } else if (options.nsfw === false) { 172 } else if (options.nsfw === false) {
@@ -386,6 +392,10 @@ export class VideosIdListQueryBuilder extends AbstractVideosQueryBuilder {
386 ) 392 )
387 } 393 }
388 394
395 private whereUUIDs (uuids: string[]) {
396 this.and.push('"video"."uuid" IN (' + createSafeIn(this.sequelize, uuids) + ')')
397 }
398
389 private whereCategoryOneOf (categoryOneOf: number[]) { 399 private whereCategoryOneOf (categoryOneOf: number[]) {
390 this.and.push('"video"."category" IN (:categoryOneOf)') 400 this.and.push('"video"."category" IN (:categoryOneOf)')
391 this.replacements.categoryOneOf = categoryOneOf 401 this.replacements.categoryOneOf = categoryOneOf