Add maximum to actor follow scores
authorChocobozzz <me@florianbigard.com>
Thu, 11 Jan 2018 17:35:39 +0000 (18:35 +0100)
committerChocobozzz <me@florianbigard.com>
Thu, 11 Jan 2018 17:35:39 +0000 (18:35 +0100)
server/models/activitypub/actor-follow.ts

index 78a65a0ff58cdaf8f937e08993cfd1c6510ad935..920c83d885bc957fa55f40affc970e59746f995b 100644 (file)
@@ -307,7 +307,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
   private static incrementScores (inboxUrls: string[], value: number, t: Sequelize.Transaction) {
     const inboxUrlsString = inboxUrls.map(url => `'${url}'`).join(',')
 
-    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"."actorId" ' +