ignore players with less than 3 playbans in autoreports

closes lichess-org/tavern#65

pretty sure we can do that for all players, not just class students
pull/8362/head
Thibault Duplessis 2021-03-12 19:54:05 +01:00
parent 6719626fe1
commit 1e662bb2f9
1 changed files with 23 additions and 17 deletions

View File

@ -192,24 +192,30 @@ final class ReportApi(
def maybeAutoPlaybanReport(userId: String): Funit =
userLoginsApi.getUserIdsWithSameIpAndPrint(userId) flatMap { ids =>
playbanApi.bans(ids.toList ::: List(userId)) flatMap { bans =>
(bans.values.sum >= 80) ?? {
userRepo.byId(userId) zip
getLichessReporter zip
findRecent(1, selectRecent(SuspectId(userId), Reason.Playbans)) flatMap {
case Some(abuser) ~ reporter ~ past if past.isEmpty =>
create(
Candidate(
reporter = reporter,
suspect = Suspect(abuser),
reason = Reason.Playbans,
text = s"${bans.values.sum} playbans over ${bans.keys.size} accounts with IP+Print match."
)
)
case _ => funit
}
playbanApi
.bans(userId :: ids.toList)
.map {
_ filter { case (_, bans) => bans > 2 }
}
.flatMap { bans =>
(bans.values.sum >= 80) ?? {
userRepo.byId(userId) zip
getLichessReporter zip
findRecent(1, selectRecent(SuspectId(userId), Reason.Playbans)) flatMap {
case Some(abuser) ~ reporter ~ past if past.isEmpty =>
create(
Candidate(
reporter = reporter,
suspect = Suspect(abuser),
reason = Reason.Playbans,
text =
s"${bans.values.sum} playbans over ${bans.keys.size} accounts with IP+Print match."
)
)
case _ => funit
}
}
}
}
}
def processAndGetBySuspect(suspect: Suspect): Fu[List[Report]] =