X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fsql%2Fvideos-id-list-query-builder.ts;h=76aafb88333cbe5d72d0a0c26db06bf88e2621b1;hb=dbd9fb44ddd880622265097bd7baf4dd71ea0861;hp=4a882e7905b3fdf08a2fb59b728fa0c24e5430ee;hpb=d324756edb836672f12284cd18e642a658b273d8;p=github%2FChocobozzz%2FPeerTube.git 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..76aafb883 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) } @@ -364,9 +367,10 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery { ' WHERE "videoShare"."videoId" = "video"."id"' + ' )' + ' OR' + - ' EXISTS (' + // Videos published by accounts we follow + ' EXISTS (' + // Videos published by channels or accounts we follow ' SELECT 1 from "actorFollow" ' + - ' WHERE "actorFollow"."targetActorId" = "account"."actorId" AND "actorFollow"."actorId" = :followerActorId ' + + ' WHERE ("actorFollow"."targetActorId" = "account"."actorId" OR "actorFollow"."targetActorId" = "videoChannel"."actorId") ' + + ' AND "actorFollow"."actorId" = :followerActorId ' + ' AND "actorFollow"."state" = \'accepted\'' + ' )' @@ -435,6 +439,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) + ')') }