diff options
author | Chocobozzz <me@florianbigard.com> | 2021-11-12 14:19:56 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-11-12 14:23:22 +0100 |
commit | 527a52ac4295a072927ff46761766a8b181a7603 (patch) | |
tree | 632f66b1691d8d72f04630671af8bdf1655d6b00 /server/models/video/sql | |
parent | 8f2608e9a9d54c87ace636f99cdb9d2a7730990f (diff) | |
download | PeerTube-527a52ac4295a072927ff46761766a8b181a7603.tar.gz PeerTube-527a52ac4295a072927ff46761766a8b181a7603.tar.zst PeerTube-527a52ac4295a072927ff46761766a8b181a7603.zip |
Add ability to filter out public videos from admin
Diffstat (limited to 'server/models/video/sql')
-rw-r--r-- | server/models/video/sql/videos-id-list-query-builder.ts | 18 |
1 files changed, 13 insertions, 5 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 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 = { | |||
40 | languageOneOf?: string[] | 40 | languageOneOf?: string[] |
41 | tagsOneOf?: string[] | 41 | tagsOneOf?: string[] |
42 | tagsAllOf?: string[] | 42 | tagsAllOf?: string[] |
43 | privacyOneOf?: VideoPrivacy[] | ||
43 | 44 | ||
44 | uuids?: string[] | 45 | uuids?: string[] |
45 | 46 | ||
@@ -138,11 +139,6 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery { | |||
138 | this.whereStateAvailable() | 139 | this.whereStateAvailable() |
139 | } | 140 | } |
140 | 141 | ||
141 | // Only list videos with the appropriate priavcy | ||
142 | if (!(options.include & VideoInclude.HIDDEN_PRIVACY)) { | ||
143 | this.wherePrivacyAvailable(options.user) | ||
144 | } | ||
145 | |||
146 | if (options.videoPlaylistId) { | 142 | if (options.videoPlaylistId) { |
147 | this.joinPlaylist(options.videoPlaylistId) | 143 | this.joinPlaylist(options.videoPlaylistId) |
148 | } | 144 | } |
@@ -187,6 +183,13 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery { | |||
187 | this.whereTagsAllOf(options.tagsAllOf) | 183 | this.whereTagsAllOf(options.tagsAllOf) |
188 | } | 184 | } |
189 | 185 | ||
186 | if (options.privacyOneOf) { | ||
187 | this.wherePrivacyOneOf(options.privacyOneOf) | ||
188 | } else { | ||
189 | // Only list videos with the appropriate priavcy | ||
190 | this.wherePrivacyAvailable(options.user) | ||
191 | } | ||
192 | |||
190 | if (options.uuids) { | 193 | if (options.uuids) { |
191 | this.whereUUIDs(options.uuids) | 194 | this.whereUUIDs(options.uuids) |
192 | } | 195 | } |
@@ -435,6 +438,11 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery { | |||
435 | ) | 438 | ) |
436 | } | 439 | } |
437 | 440 | ||
441 | private wherePrivacyOneOf (privacyOneOf: VideoPrivacy[]) { | ||
442 | this.and.push('"video"."privacy" IN (:privacyOneOf)') | ||
443 | this.replacements.privacyOneOf = privacyOneOf | ||
444 | } | ||
445 | |||
438 | private whereUUIDs (uuids: string[]) { | 446 | private whereUUIDs (uuids: string[]) { |
439 | this.and.push('"video"."uuid" IN (' + createSafeIn(this.sequelize, uuids) + ')') | 447 | this.and.push('"video"."uuid" IN (' + createSafeIn(this.sequelize, uuids) + ')') |
440 | } | 448 | } |