Skip to content

Commit 72926d8

Browse files
Force Cheat reports to contain at least one game link
1 parent 7bdb6b1 commit 72926d8

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

conf/base.conf

+1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ report {
311311
collection.report = report2
312312
actor.name = report
313313
score.threshold = 50
314+
net.domain = ${net.domain}
314315
}
315316
i18n {
316317
web_path.relative = ${app.web_path}/trans

modules/i18n/src/main/I18nKeys.scala

+1
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ val `insult` = new Translated("insult", Site)
408408
val `troll` = new Translated("troll", Site)
409409
val `other` = new Translated("other", Site)
410410
val `reportDescriptionHelp` = new Translated("reportDescriptionHelp", Site)
411+
val `error.provideOneCheatedGameLink` = new Translated("error.provideOneCheatedGameLink", Site)
411412
val `by` = new Translated("by", Site)
412413
val `thisTopicIsNowClosed` = new Translated("thisTopicIsNowClosed", Site)
413414
val `theming` = new Translated("theming", Site)

modules/report/src/main/DataForm.scala

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@ package lila.report
22

33
import play.api.data._
44
import play.api.data.Forms._
5+
import play.api.data.validation._
56
import play.api.data.validation.Constraints._
67

78
import lila.user.{ User, UserRepo }
89

9-
private[report] final class DataForm(val captcher: akka.actor.ActorSelection) extends lila.hub.CaptchedForm {
10+
private[report] final class DataForm(val captcher: akka.actor.ActorSelection, val domain: String) extends lila.hub.CaptchedForm {
11+
val cheatLinkConstraint: Constraint[ReportSetup] = Constraint("constraints.cheatgamelink")({ setup =>
12+
if (setup.reason != "cheat" || (domain + """/(\w{8}|\w{12})""").r.findFirstIn(setup.text).isDefined)
13+
Valid
14+
else
15+
Invalid(Seq(ValidationError("error.provideOneCheatedGameLink")))
16+
})
1017

1118
val create = Form(mapping(
1219
"username" -> nonEmptyText.verifying("Unknown username", { fetchUser(_).isDefined }),
@@ -22,7 +29,7 @@ private[report] final class DataForm(val captcher: akka.actor.ActorSelection) ex
2229
gameId = gameId,
2330
move = move
2431
)
25-
})(_.export.some).verifying(captchaFailMessage, validateCaptcha _))
32+
})(_.export.some).verifying(captchaFailMessage, validateCaptcha _).verifying(cheatLinkConstraint))
2633

2734
def createWithCaptcha = withCaptcha(create)
2835

modules/report/src/main/Env.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ final class Env(
1919
private val CollectionReport = config getString "collection.report"
2020
private val ActorName = config getString "actor.name"
2121
private val ScoreThreshold = config getInt "score.threshold"
22+
private val NetDomain = config getString "net.domain"
2223

2324
val scoreThresholdSetting = settingStore[Int](
2425
"reportScoreThreshold",
2526
default = ScoreThreshold,
2627
text = "Report score threshold. Reports with lower scores are concealed to moderators".some
2728
)
2829

29-
lazy val forms = new DataForm(hub.actor.captcher)
30+
lazy val forms = new DataForm(hub.actor.captcher, NetDomain)
3031

3132
private lazy val autoAnalysis = new AutoAnalysis(
3233
fishnet = hub.actor.fishnet,

translation/source/site.xml

+1
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ a computer analysis, a game chat and a shareable URL.</string>
509509
<string name="troll">Troll</string>
510510
<string name="other">Other</string>
511511
<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>
512+
<string name="error.provideOneCheatedGameLink">Please provide at least one link to a cheated game.</string>
512513
<string name="by">by %s</string>
513514
<string name="thisTopicIsNowClosed">This topic is now closed.</string>
514515
<string name="theming">Theming</string>

0 commit comments

Comments
 (0)