Skip to content

Commit

Permalink
auto-check troll reports on mod action
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Apr 28, 2015
1 parent 4f6b714 commit 749cd49
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions modules/hub/src/main/actorApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ case class Cheater(userId: String, text: String)
case class Clean(userId: String)
case class Check(userId: String)
case class MarkCheater(userId: String, by: String)
case class MarkTroll(userId: String, by: String)
case class Shutup(userId: String, text: String)
}

Expand Down
3 changes: 2 additions & 1 deletion modules/mod/src/main/ModApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ final class ModApi(
def troll(mod: String, username: String): Fu[Boolean] = withUser(username) { u =>
val user = u.copy(troll = !u.troll)
((UserRepo updateTroll user) >>-
logApi.troll(mod, user.id, user.troll)) inject user.troll
logApi.troll(mod, user.id, user.troll)) >>-
(reporter ! lila.hub.actorApi.report.MarkTroll(user.id, mod)) inject user.troll
}

def ban(mod: String, username: String): Funit = withUser(username) { user =>
Expand Down
2 changes: 2 additions & 0 deletions modules/report/src/main/Env.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ final class Env(
api.autoProcess(userId)
case lila.hub.actorApi.report.MarkCheater(userId, by) =>
api.processEngine(userId, by)
case lila.hub.actorApi.report.MarkTroll(userId, by) =>
api.processTroll(userId, by)
case lila.hub.actorApi.report.Shutup(userId, text) =>
api.autoInsultReport(userId, text)
}
Expand Down
8 changes: 8 additions & 0 deletions modules/report/src/main/ReportApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ private[report] final class ReportApi {
$set("processedBy" -> byModId),
multi = true)

def processTroll(userId: String, byModId: String): Funit = $update(
Json.obj(
"user" -> userId,
"reason" -> $or(List(Reason.Insult.name, Reason.Troll.name, Reason.Other.name))
) ++ unprocessedSelect,
$set("processedBy" -> byModId),
multi = true)

def autoInsultReport(userId: String, text: String): Funit = {
UserRepo byId userId zip UserRepo.lichess flatMap {
case (Some(user), Some(lichess)) => create(ReportSetup(
Expand Down

0 comments on commit 749cd49

Please sign in to comment.