Skip to content

Commit

Permalink
Add mod log entries for games lost by cheat detection
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-daniels committed Sep 27, 2017
1 parent c494322 commit 786904e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions modules/hub/src/main/actorApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions modules/mod/src/main/Env.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 2 additions & 0 deletions modules/mod/src/main/Modlog.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -99,4 +100,5 @@ object Modlog {
val unreportban = "unreportban"
val modMessage = "modMessage"
val coachReview = "coachReview"
val cheatDetected = "cheatDetected"
}
4 changes: 4 additions & 0 deletions modules/mod/src/main/ModlogApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion modules/round/src/main/Env.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down
6 changes: 5 additions & 1 deletion modules/round/src/main/Round.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
}
}
Expand Down

0 comments on commit 786904e

Please sign in to comment.