Fix video follow SQL

pull/2861/head
Chocobozzz 2020-06-09 15:59:35 +02:00 committed by Chocobozzz
parent 5fb2e2888c
commit f046e2fa5c
2 changed files with 5 additions and 3 deletions

View File

@ -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) {

View File

@ -1366,7 +1366,7 @@ export class VideoModel extends Model<VideoModel> {
// 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 = {