From 527a52ac4295a072927ff46761766a8b181a7603 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 12 Nov 2021 14:19:56 +0100 Subject: Add ability to filter out public videos from admin --- .../models/video/sql/videos-id-list-query-builder.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'server/models/video/sql/videos-id-list-query-builder.ts') 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 4a882e790..d825225ab 100644 --- a/server/models/video/sql/videos-id-list-query-builder.ts +++ b/server/models/video/sql/videos-id-list-query-builder.ts @@ -40,6 +40,7 @@ export type BuildVideosListQueryOptions = { languageOneOf?: string[] tagsOneOf?: string[] tagsAllOf?: string[] + privacyOneOf?: VideoPrivacy[] uuids?: string[] @@ -138,11 +139,6 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery { this.whereStateAvailable() } - // Only list videos with the appropriate priavcy - if (!(options.include & VideoInclude.HIDDEN_PRIVACY)) { - this.wherePrivacyAvailable(options.user) - } - if (options.videoPlaylistId) { this.joinPlaylist(options.videoPlaylistId) } @@ -187,6 +183,13 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery { this.whereTagsAllOf(options.tagsAllOf) } + if (options.privacyOneOf) { + this.wherePrivacyOneOf(options.privacyOneOf) + } else { + // Only list videos with the appropriate priavcy + this.wherePrivacyAvailable(options.user) + } + if (options.uuids) { this.whereUUIDs(options.uuids) } @@ -435,6 +438,11 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery { ) } + private wherePrivacyOneOf (privacyOneOf: VideoPrivacy[]) { + this.and.push('"video"."privacy" IN (:privacyOneOf)') + this.replacements.privacyOneOf = privacyOneOf + } + private whereUUIDs (uuids: string[]) { this.and.push('"video"."uuid" IN (' + createSafeIn(this.sequelize, uuids) + ')') } -- cgit v1.2.3