From: Chocobozzz Date: Wed, 23 Oct 2019 10:06:26 +0000 (+0200) Subject: Fix and cleanup actor follow inbox sql query X-Git-Tag: v2.0.0-rc.1~20 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=862ead21a3d268677977a25bdb6853003299cf71;p=oweals%2Fpeertube.git Fix and cleanup actor follow inbox sql query --- diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts index fb3c4ef9d..24272a40e 100644 --- a/server/models/activitypub/actor-follow.ts +++ b/server/models/activitypub/actor-follow.ts @@ -574,8 +574,8 @@ export class ActorFollowModel extends Model { } const selections: string[] = [] - if (distinct === true) selections.push('DISTINCT("Follows"."' + columnUrl + '") AS "selectionUrl"') - else selections.push('"Follows"."' + columnUrl + '" AS "selectionUrl"') + if (distinct === true) selections.push(`DISTINCT("Follows"."${columnUrl}") AS "selectionUrl"`) + else selections.push(`"Follows"."${columnUrl}" AS "selectionUrl"`) selections.push('COUNT(*) AS "total"') @@ -585,7 +585,7 @@ export class ActorFollowModel extends Model { let query = 'SELECT ' + selection + ' FROM "actor" ' + 'INNER JOIN "actorFollow" ON "actorFollow"."' + firstJoin + '" = "actor"."id" ' + 'INNER JOIN "actor" AS "Follows" ON "actorFollow"."' + secondJoin + '" = "Follows"."id" ' + - 'WHERE "actor"."id" = ANY ($actorIds) AND "actorFollow"."state" = \'accepted\' AND "selectionUrl" IS NOT NULL ' + `WHERE "actor"."id" = ANY ($actorIds) AND "actorFollow"."state" = 'accepted' AND "Follows"."${columnUrl}" IS NOT NULL ` if (count !== undefined) query += 'LIMIT ' + count if (start !== undefined) query += ' OFFSET ' + start