From 786904e8165f402b89054f2dc6702acfe5b372b0 Mon Sep 17 00:00:00 2001 From: ProgramFOX Date: Wed, 27 Sep 2017 16:07:41 +0200 Subject: [PATCH] Add mod log entries for games lost by cheat detection --- modules/hub/src/main/actorApi.scala | 1 + modules/mod/src/main/Env.scala | 1 + modules/mod/src/main/Modlog.scala | 2 ++ modules/mod/src/main/ModlogApi.scala | 4 ++++ modules/round/src/main/Env.scala | 3 ++- modules/round/src/main/Round.scala | 6 +++++- 6 files changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/hub/src/main/actorApi.scala b/modules/hub/src/main/actorApi.scala index 495c2fb0409f..12e606b83580 100644 --- a/modules/hub/src/main/actorApi.scala +++ b/modules/hub/src/main/actorApi.scala @@ -59,6 +59,7 @@ package mod { case class MarkBooster(userId: String) case class ChatTimeout(mod: String, user: String, reason: String) case class KickFromRankings(userId: String) + case class CheatDetected(userId: String, gameId: String) } package captcha { diff --git a/modules/mod/src/main/Env.scala b/modules/mod/src/main/Env.scala index cd04843b38f0..be4ac41368d5 100644 --- a/modules/mod/src/main/Env.scala +++ b/modules/mod/src/main/Env.scala @@ -122,6 +122,7 @@ final class Env( assessApi.onGameReady(game, whiteUser, blackUser) } case lila.hub.actorApi.mod.ChatTimeout(mod, user, reason) => logApi.chatTimeout(mod, user, reason) + case lila.hub.actorApi.mod.CheatDetected(userId, gameId) => logApi.cheatDetected(userId, gameId) } }), name = ActorName), 'finishGame, 'analysisReady) } diff --git a/modules/mod/src/main/Modlog.scala b/modules/mod/src/main/Modlog.scala index 205007cc59b6..5479492f1b0c 100644 --- a/modules/mod/src/main/Modlog.scala +++ b/modules/mod/src/main/Modlog.scala @@ -48,6 +48,7 @@ case class Modlog( case Modlog.unreportban => "un-reportban" case Modlog.modMessage => "send message" case Modlog.coachReview => "disapprove coach review" + case Modlog.cheatDetected => "game lost by cheat detection" case a => a } @@ -99,4 +100,5 @@ object Modlog { val unreportban = "unreportban" val modMessage = "modMessage" val coachReview = "coachReview" + val cheatDetected = "cheatDetected" } diff --git a/modules/mod/src/main/ModlogApi.scala b/modules/mod/src/main/ModlogApi.scala index c5314360cac4..3a2139777e02 100644 --- a/modules/mod/src/main/ModlogApi.scala +++ b/modules/mod/src/main/ModlogApi.scala @@ -122,6 +122,10 @@ final class ModlogApi(coll: Coll) { Modlog(mod, coach.some, Modlog.coachReview, details = s"by $author".some) } + def cheatDetected(user: String, gameId: String) = add { + Modlog("lichess", user.some, Modlog.cheatDetected, details = s"game $gameId".some) + } + def recent = coll.find($empty).sort($sort naturalDesc).cursor[Modlog]().gather[List](100) def wasUnengined(sus: Suspect) = coll.exists($doc( diff --git a/modules/round/src/main/Env.scala b/modules/round/src/main/Env.scala index 0e7c60a97eac..57fe36fabeee 100644 --- a/modules/round/src/main/Env.scala +++ b/modules/round/src/main/Env.scala @@ -76,7 +76,8 @@ final class Env( forecastApi = forecastApi, socketHub = socketHub, moretimeDuration = Moretime, - activeTtl = ActiveTtl + activeTtl = ActiveTtl, + modLog = lila.hub.Env.current.actor.mod ) def receive: Receive = ({ case actorApi.GetNbRounds => diff --git a/modules/round/src/main/Round.scala b/modules/round/src/main/Round.scala index b462de90f579..2ce025195269 100644 --- a/modules/round/src/main/Round.scala +++ b/modules/round/src/main/Round.scala @@ -26,7 +26,8 @@ private[round] final class Round( forecastApi: ForecastApi, socketHub: ActorRef, moretimeDuration: FiniteDuration, - activeTtl: Duration + activeTtl: Duration, + modLog: akka.actor.ActorSelection ) extends SequentialActor { context setReceiveTimeout activeTtl @@ -139,6 +140,9 @@ private[round] final class Round( case DrawForce => handle(drawer force _) case Cheat(color) => handle { game => (game.playable && !game.imported) ?? { + game.player(color).userId.foreach { player => + modLog ! lila.hub.actorApi.mod.CheatDetected(player, gameId) + } finisher.other(game, _.Cheat, Some(!color)) } }