From f046e2fa5c2af98f378056206ef65347f4b29b8d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 9 Jun 2020 15:59:35 +0200 Subject: [PATCH] Fix video follow SQL --- server/models/video/video-query-builder.ts | 6 ++++-- server/models/video/video.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/server/models/video/video-query-builder.ts b/server/models/video/video-query-builder.ts index 455f9f30f..6211c9e56 100644 --- a/server/models/video/video-query-builder.ts +++ b/server/models/video/video-query-builder.ts @@ -135,12 +135,14 @@ function buildListQuery (model: typeof Model, options: BuildVideosQueryOptions) ' EXISTS (' + ' SELECT 1 FROM "videoShare" ' + ' INNER JOIN "actorFollow" "actorFollowShare" ON "actorFollowShare"."targetActorId" = "videoShare"."actorId" ' + - ' AND "actorFollowShare"."actorId" = :followerActorId WHERE "videoShare"."videoId" = "video"."id"' + + ' AND "actorFollowShare"."actorId" = :followerActorId AND "actorFollowShare"."state" = \'accepted\' ' + + ' WHERE "videoShare"."videoId" = "video"."id"' + ' )' + ' OR' + ' EXISTS (' + ' SELECT 1 from "actorFollow" ' + - ' WHERE "actorFollow"."targetActorId" = "videoChannel"."actorId" AND "actorFollow"."actorId" = :followerActorId' + + ' WHERE "actorFollow"."targetActorId" = "videoChannel"."actorId" AND "actorFollow"."actorId" = :followerActorId ' + + ' AND "actorFollow"."state" = \'accepted\'' + ' )' if (options.includeLocalVideos) { diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 344bfc929..5aa40220e 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -1366,7 +1366,7 @@ export class VideoModel extends Model { // Instances only share videos const query = 'SELECT 1 FROM "videoShare" ' + 'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = "videoShare"."actorId" ' + - 'WHERE "actorFollow"."actorId" = $followerActorId AND "videoShare"."videoId" = $videoId ' + + 'WHERE "actorFollow"."actorId" = $followerActorId AND "actorFollow"."state" = \'accepted\' AND "videoShare"."videoId" = $videoId ' + 'LIMIT 1' const options = {