+ type: QueryTypes.BULKUPDATE,
+ transaction: t
+ }
+
+ return ActorFollowModel.sequelize.query(query, options)
+ }
+
+ static async updateScoreByFollowingServers (serverIds: number[], value: number, t?: Transaction) {
+ if (serverIds.length === 0) return
+
+ const me = await getServerActor()
+ const serverIdsString = createSafeIn(ActorFollowModel, serverIds)
+
+ 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" ' +
+ `WHERE "actorFollow"."actorId" = ${me.Account.actorId} ` + // I'm the follower
+ `AND "actor"."serverId" IN (${serverIdsString})` + // Criteria on followings
+ ')'
+
+ const options = {
+ type: QueryTypes.BULKUPDATE,