Merge pull request #4554 from ProgramFOX/cheat-report-force-game-link

Force Cheat reports to contain at least one game link
pull/4557/head
Thibault Duplessis 2018-08-23 11:22:05 +02:00 committed by GitHub
commit 428af91993
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 3 deletions

View File

@ -310,6 +310,7 @@ report {
collection.report = report2
actor.name = report
score.threshold = 50
net.domain = ${net.domain}
}
i18n {
web_path.relative = ${app.web_path}/trans

View File

@ -408,6 +408,7 @@ val `insult` = new Translated("insult", Site)
val `troll` = new Translated("troll", Site)
val `other` = new Translated("other", Site)
val `reportDescriptionHelp` = new Translated("reportDescriptionHelp", Site)
val `error.provideOneCheatedGameLink` = new Translated("error.provideOneCheatedGameLink", Site)
val `by` = new Translated("by", Site)
val `thisTopicIsNowClosed` = new Translated("thisTopicIsNowClosed", Site)
val `theming` = new Translated("theming", Site)

View File

@ -2,11 +2,18 @@ package lila.report
import play.api.data._
import play.api.data.Forms._
import play.api.data.validation._
import play.api.data.validation.Constraints._
import lila.user.{ User, UserRepo }
private[report] final class DataForm(val captcher: akka.actor.ActorSelection) extends lila.hub.CaptchedForm {
private[report] final class DataForm(val captcher: akka.actor.ActorSelection, val domain: String) extends lila.hub.CaptchedForm {
val cheatLinkConstraint: Constraint[ReportSetup] = Constraint("constraints.cheatgamelink")({ setup =>
if (setup.reason != "cheat" || (domain + """/(\w{8}|\w{12})""").r.findFirstIn(setup.text).isDefined)
Valid
else
Invalid(Seq(ValidationError("error.provideOneCheatedGameLink")))
})
val create = Form(mapping(
"username" -> nonEmptyText.verifying("Unknown username", { fetchUser(_).isDefined }),
@ -22,7 +29,7 @@ private[report] final class DataForm(val captcher: akka.actor.ActorSelection) ex
gameId = gameId,
move = move
)
})(_.export.some).verifying(captchaFailMessage, validateCaptcha _))
})(_.export.some).verifying(captchaFailMessage, validateCaptcha _).verifying(cheatLinkConstraint))
def createWithCaptcha = withCaptcha(create)

View File

@ -19,6 +19,7 @@ final class Env(
private val CollectionReport = config getString "collection.report"
private val ActorName = config getString "actor.name"
private val ScoreThreshold = config getInt "score.threshold"
private val NetDomain = config getString "net.domain"
val scoreThresholdSetting = settingStore[Int](
"reportScoreThreshold",
@ -26,7 +27,7 @@ final class Env(
text = "Report score threshold. Reports with lower scores are concealed to moderators".some
)
lazy val forms = new DataForm(hub.actor.captcher)
lazy val forms = new DataForm(hub.actor.captcher, NetDomain)
private lazy val autoAnalysis = new AutoAnalysis(
fishnet = hub.actor.fishnet,

View File

@ -509,6 +509,7 @@ a computer analysis, a game chat and a shareable URL.</string>
<string name="troll">Troll</string>
<string name="other">Other</string>
<string name="reportDescriptionHelp">Paste the link to the game(s) and explain what is wrong about this user behavior. Don't just say "they cheat", but tell us how you came to this conclusion. Your report will be processed faster if written in English.</string>
<string name="error.provideOneCheatedGameLink">Please provide at least one link to a cheated game.</string>
<string name="by">by %s</string>
<string name="thisTopicIsNowClosed">This topic is now closed.</string>
<string name="theming">Theming</string>