Limit maximum actor follow score
authorChocobozzz <me@florianbigard.com>
Tue, 6 Aug 2019 15:30:09 +0000 (17:30 +0200)
committerChocobozzz <me@florianbigard.com>
Wed, 7 Aug 2019 10:07:58 +0000 (12:07 +0200)
server/models/activitypub/actor-follow.ts

index 99a5fd117db552d8a34a87aff0c1c319e3e78bee..51b09e09be14c039d7fcc712bbf6d81ee660fc88 100644 (file)
@@ -486,7 +486,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
     const me = await getServerActor()
     const serverIdsString = createSafeIn(ActorFollowModel, serverIds)
 
-    const query = `UPDATE "actorFollow" SET "score" = "score" + ${value} ` +
+    const query = `UPDATE "actorFollow" SET "score" = LEAST("score" + ${value}, ${ACTOR_FOLLOW_SCORE.MAX}) ` +
       'WHERE id IN (' +
         'SELECT "actorFollow"."id" FROM "actorFollow" ' +
         'INNER JOIN "actor" ON "actor"."id" = "actorFollow"."targetActorId" ' +