break the autoreport loop - closes 4025
parent
346f29a603
commit
5ae6073016
|
@ -93,7 +93,7 @@ object Report {
|
|||
) {
|
||||
def simplifiedText = text.lines.filterNot(_ startsWith "[AUTOREPORT]") mkString "\n"
|
||||
|
||||
def byHuman = by.value != "lichess" && by.value != "irwin"
|
||||
def byHuman = by != ReporterId.lichess && by != ReporterId.irwin
|
||||
}
|
||||
|
||||
case class Inquiry(mod: User.ID, seenAt: DateTime)
|
||||
|
|
|
@ -74,17 +74,19 @@ final class ReportApi(
|
|||
}
|
||||
|
||||
def autoCheatReport(userId: String, text: String): Funit =
|
||||
getSuspect(userId) zip getLichessReporter flatMap {
|
||||
case (Some(suspect), reporter) =>
|
||||
lila.mon.cheat.autoReport.count()
|
||||
create(Report.Candidate(
|
||||
reporter = reporter,
|
||||
suspect = suspect,
|
||||
reason = Reason.Cheat,
|
||||
text = text
|
||||
))
|
||||
case _ => funit
|
||||
}
|
||||
getSuspect(userId) zip
|
||||
getLichessReporter zip
|
||||
findRecent(1, selectRecent(SuspectId(userId), Reason.Cheat)).map(_.flatMap(_.atoms.toList)) flatMap {
|
||||
case Some(suspect) ~ reporter ~ atoms if atoms.forall(_.byHuman) =>
|
||||
lila.mon.cheat.autoReport.count()
|
||||
create(Report.Candidate(
|
||||
reporter = reporter,
|
||||
suspect = suspect,
|
||||
reason = Reason.Cheat,
|
||||
text = text
|
||||
))
|
||||
case _ => funit
|
||||
}
|
||||
|
||||
def autoBotReport(userId: String, referer: Option[String], name: String): Funit =
|
||||
getSuspect(userId) zip getLichessReporter flatMap {
|
||||
|
@ -290,9 +292,9 @@ final class ReportApi(
|
|||
coll.find(selector).sort($sort desc "score").list[Report](nb)
|
||||
}
|
||||
|
||||
private def selectRecent(suspect: Suspect, reason: Reason): Bdoc = $doc(
|
||||
private def selectRecent(suspect: SuspectId, reason: Reason): Bdoc = $doc(
|
||||
"atoms.0.at" $gt DateTime.now.minusDays(7),
|
||||
"user" -> suspect.user.id,
|
||||
"user" -> suspect.value,
|
||||
"reason" -> reason.key
|
||||
)
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ case class Reporter(user: User) extends AnyVal {
|
|||
case class ReporterId(value: User.ID) extends AnyVal
|
||||
|
||||
object ReporterId {
|
||||
def lichess = ReporterId("lichess")
|
||||
def irwin = ReporterId("irwin")
|
||||
implicit val reporterIdIso = lila.common.Iso.string[ReporterId](ReporterId.apply, _.value)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue