unify comm reports

db.report2.update({room:'coms'},{$set:{room:'comm'}},{multi:1})
This commit is contained in:
Thibault Duplessis 2019-09-27 16:25:16 +02:00
parent a04ced949c
commit 8644c1938d
8 changed files with 23 additions and 27 deletions

View file

@ -43,7 +43,7 @@ object Report extends LilaController {
private def onInquiryStart(inquiry: ReportModel) =
inquiry.room match {
case Room.Coms => Redirect(routes.Mod.communicationPrivate(inquiry.user))
case Room.Comm => Redirect(routes.Mod.communicationPrivate(inquiry.user))
case _ => Mod.redirect(inquiry.user)
}

View file

@ -42,8 +42,8 @@ trait SetupHelper { self: I18nHelper =>
def translatedReasonChoices(implicit ctx: Context) = List(
(Reason.Cheat.key, trans.cheat.txt()),
(Reason.Insult.key, trans.insult.txt()),
(Reason.Troll.key, trans.troll.txt()),
(Reason.Comm.key, trans.insult.txt()),
(Reason.Comm.key, trans.troll.txt()),
(Reason.Other.key, trans.other.txt())
)

View file

@ -61,7 +61,7 @@ object list {
),
tbody(
reports.map {
case WithSuspect(r, sus, _) if !r.isAboutComm || isGranted(_.Shadowban) =>
case WithSuspect(r, sus, _) if !r.isComm || isGranted(_.Shadowban) =>
tr(cls := List("new" -> r.open))(
td(
reportScore(r.score),

View file

@ -76,7 +76,7 @@ final class ModApi(
lilaBus.publish(lila.hub.actorApi.mod.Shadowban(sus.user.id, value), 'shadowban)
}
} >>
reportApi.process(mod, sus, Set(Room.Coms)) >>- {
reportApi.process(mod, sus, Set(Room.Comm)) >>- {
if (value) notifier.reporters(mod, sus)
} inject sus
}

View file

@ -13,16 +13,16 @@ object Reason {
case object CheatPrint extends Reason {
override def name = "Print"
}
case object Insult extends Reason
case object Troll extends Reason
case object CommFlag extends Reason
case object Comm extends Reason {
def flagText = "[FLAG]"
}
case object Boost extends Reason
case object Other extends Reason
case object Playbans extends Reason
val communication: Set[Reason] = Set(Insult, Troll, CommFlag, Other)
// val communication: Set[Reason] = Set(Insult, Troll, CommFlag, Other)
val all = List(Cheat, CheatPrint, Insult, Troll, Boost, CommFlag, Other)
val all = List(Cheat, CheatPrint, Comm, Boost, Other)
val keys = all map (_.key)
val byKey = all map { v => (v.key, v) } toMap
@ -35,11 +35,8 @@ object Reason {
def isCheat = reason == Cheat
def isOther = reason == Other
def isTroll = reason == Troll
def isInsult = reason == Insult
def isCommFlag = reason == CommFlag
def isPrint = reason == CheatPrint
def isAboutComm = isTroll || isInsult || isCommFlag
def isComm = reason == Comm
def isPlaybans = reason == Playbans
}
}

View file

@ -55,9 +55,7 @@ case class Report(
def unprocessedCheat = open && isCheat
def unprocessedOther = open && isOther
def unprocessedTroll = open && isTroll
def unprocessedInsult = open && isInsult
def unprocessedAboutComm = open && isAboutComm
def unprocessedComm = open && isComm
def process(by: User) = copy(
open = false,
@ -66,7 +64,7 @@ case class Report(
def userIds: List[User.ID] = user :: atoms.toList.map(_.by.value)
def isRecentComm = room == Room.Coms && open
def isRecentComm = room == Room.Comm && open
def isRecentCommOf(sus: Suspect) = isRecentComm && user == sus.user.id
def boostWith: Option[User.ID] = (reason == Reason.Boost) ?? {
@ -126,8 +124,9 @@ object Report {
) extends Reason.WithReason {
def scored(score: Score) = Candidate.Scored(this, score)
def isAutomatic = reporter.id == ReporterId.lichess
def isAutoComm = isAutomatic && isAboutComm
def isAutoComm = isAutomatic && isComm
def isCoachReview = isOther && text.contains("COACH REVIEW")
def isCommFlag = text contains Reason.Comm.flagText
}
object Candidate {

View file

@ -47,8 +47,8 @@ final class ReportApi(
def commFlag(reporter: Reporter, suspect: Suspect, resource: String, text: String) = create(Candidate(
reporter,
suspect,
Reason.CommFlag,
s"[FLAG] $resource ${text take 140}"
Reason.Comm,
s"${Reason.Comm.flagText} $resource ${text take 140}"
))
private def monitorOpen = {
@ -61,7 +61,7 @@ final class ReportApi(
private def isAlreadySlain(candidate: Candidate) =
(candidate.isCheat && candidate.suspect.user.engine) ||
(candidate.isAutomatic && candidate.isOther && candidate.suspect.user.troll) ||
(candidate.isAboutComm && candidate.suspect.user.troll)
(candidate.isComm && candidate.suspect.user.troll)
def getMod(username: String): Fu[Option[Mod]] =
UserRepo named username map2 Mod.apply
@ -193,7 +193,7 @@ final class ReportApi(
Candidate(
reporter = reporter,
suspect = suspect,
reason = Reason.Insult,
reason = Reason.Comm,
text = text
),
score => if (major) Report.Score(score.value atLeast scoreThreshold()) else score

View file

@ -11,13 +11,13 @@ object Room {
case object Cheat extends Room
case object Print extends Room
case object Coms extends Room
case object Comm extends Room
case object Other extends Room
case object Xfiles extends Room {
override def name = "X-Files"
}
val all: List[Room] = List(Cheat, Print, Coms, Other, Xfiles)
val all: List[Room] = List(Cheat, Print, Comm, Other, Xfiles)
val byKey = all map { v => (v.key, v) } toMap
implicit val roomIso = lila.common.Iso[String, Room](k => byKey.getOrElse(k, Other), _.key)
@ -27,14 +27,14 @@ object Room {
def apply(reason: Reason): Room = reason match {
case Reason.Cheat => Cheat
case Reason.CheatPrint => Print
case Reason.Troll | Reason.Insult | Reason.CommFlag => Coms
case Reason.Comm => Comm
case Reason.Boost | Reason.Playbans | Reason.Other => Other
}
def toReasons(room: Room): Set[Reason] = room match {
case Cheat => Set(Reason.Cheat)
case Print => Set(Reason.CheatPrint)
case Coms => Set(Reason.Troll, Reason.Insult, Reason.CommFlag)
case Comm => Set(Reason.Comm)
case Other => Set(Reason.Boost, Reason.Other)
case Xfiles => Set.empty
}