prize tournaments warning passlist

pull/7042/head
Thibault Duplessis 2020-07-24 09:55:29 +02:00
parent 139c04e7a6
commit 1eea2b1784
11 changed files with 41 additions and 19 deletions

View File

@ -3,6 +3,7 @@ package lila.app
import akka.actor._
import com.softwaremill.macwire._
import lila.memo.SettingStore.Strings._
import lila.memo.SettingStore.UserIds._
import play.api.libs.ws.WSClient
import play.api.mvc.{ ControllerComponents, SessionCookieBaker }
import play.api.{ Configuration, Environment, Mode }
@ -11,6 +12,7 @@ import scala.concurrent.{ ExecutionContext, Future }
import lila.common.config._
import lila.common.{ Bus, Lilakka, Strings }
import lila.common.UserIds
final class Env(
val config: Configuration,
@ -113,7 +115,12 @@ final class Env(
lazy val featuredTeamsSetting = memo.settingStore[Strings](
"featuredTeams",
default = Strings(Nil),
text = "Team IDs that always get their tournaments visible on /tournament".some
text = "Team IDs that always get their tournaments visible on /tournament. Separated by commas.".some
)
lazy val prizeTournamentMakers = memo.settingStore[UserIds](
"prizeTournamentMakers ",
default = UserIds(Nil),
text = "User IDs who can make prize tournaments (arena & swiss) without a warning. Separated by commas.".some
)
lazy val preloader = wire[mashup.Preload]

View File

@ -21,7 +21,8 @@ final class Dev(env: Env) extends LilaController(env) {
env.plan.donationGoalSetting,
env.apiTimelineSetting,
env.noDelaySecretSetting,
env.featuredTeamsSetting
env.featuredTeamsSetting,
env.prizeTournamentMakers
)
def settings =

View File

@ -47,7 +47,7 @@ object side {
s.settings.description map { d =>
st.section(cls := "description")(richText(d))
},
s.looksLikePrize option views.html.tournament.bits.userPrizeDisclaimer,
s.looksLikePrize option views.html.tournament.bits.userPrizeDisclaimer(s.createdBy),
teamLink(s.teamId),
separator,
absClientDateTime(s.startsAt)

View File

@ -42,12 +42,13 @@ object bits {
}
)
def userPrizeDisclaimer =
div(cls := "tour__prize")(
"This tournament is NOT organized by Lichess.",
br,
"If it has prizes, Lichess is NOT responsible for paying them."
)
def userPrizeDisclaimer(ownerId: lila.user.User.ID) =
!env.prizeTournamentMakers.get().value.contains(ownerId) option
div(cls := "tour__prize")(
"This tournament is NOT organized by Lichess.",
br,
"If it has prizes, Lichess is NOT responsible for paying them."
)
def jsI18n(implicit ctx: Context) = i18nJsObject(i18nKeys)

View File

@ -63,7 +63,7 @@ object side {
tour.description map { d =>
st.section(cls := "description")(richText(d))
},
tour.looksLikePrize option bits.userPrizeDisclaimer,
tour.looksLikePrize option bits.userPrizeDisclaimer(tour.createdBy),
verdicts.relevant option st.section(
dataIcon := "7",
cls := List(

View File

@ -32,6 +32,11 @@ object Iso {
str => Strings(str.split(sep).iterator.map(_.trim).to(List)),
strs => strs.value mkString sep
)
def userIds(sep: String): StringIso[UserIds] =
Iso[String, UserIds](
str => UserIds(str.split(sep).iterator.map(_.trim.toLowerCase).to(List)),
strs => strs.value mkString sep
)
implicit def isoIdentity[A]: Iso[A, A] = apply(identity[A] _, identity[A] _)

View File

@ -120,6 +120,7 @@ object Domain {
}
case class Strings(value: List[String]) extends AnyVal
case class UserIds(value: List[String]) extends AnyVal
case class Every(value: FiniteDuration) extends AnyVal
case class AtMost(value: FiniteDuration) extends AnyVal

View File

@ -76,6 +76,11 @@ object SettingStore {
implicit val stringsBsonHandler = lila.db.dsl.isoHandler(stringsIso)
implicit val stringsReader = StringReader.fromIso(stringsIso)
}
object UserIds {
val userIdsIso = lila.common.Iso.userIds(",")
implicit val userIdsBsonHandler = lila.db.dsl.isoHandler(userIdsIso)
implicit val userIdsReader = StringReader.fromIso(userIdsIso)
}
object Regex {
val regexIso = lila.common.Iso.string[Regex](_.r, _.toString)
implicit val regexBsonHandler = lila.db.dsl.isoHandler(regexIso)
@ -97,6 +102,9 @@ object SettingStore {
implicit val stringsFormable = new Formable[lila.common.Strings](v =>
Form(single("v" -> text)) fill Strings.stringsIso.to(v)
)
implicit val userIdsFormable = new Formable[lila.common.UserIds](v =>
Form(single("v" -> text)) fill UserIds.userIdsIso.to(v)
)
}
private val dbField = "setting"

View File

@ -41,13 +41,12 @@ final class Env(
private lazy val photographer = new lila.db.Photographer(imageRepo, "streamer")
lazy val alwaysFeaturedSetting = {
import lila.memo.SettingStore.Strings._
import lila.common.Strings
settingStore[Strings](
import lila.memo.SettingStore.UserIds._
import lila.common.UserIds
settingStore[UserIds](
"streamerAlwaysFeatured",
default = Strings(Nil),
text =
"Twitch streamers who get featured without the keyword - lichess usernames separated by a comma".some
default = UserIds(Nil),
text = "Twitch streamers who get featured without the keyword - lichess usernames separated by a comma".some
)
}

View File

@ -17,7 +17,7 @@ final private class Streaming(
isOnline: User.ID => Boolean,
timeline: lila.hub.actors.Timeline,
keyword: Stream.Keyword,
alwaysFeatured: () => lila.common.Strings,
alwaysFeatured: () => lila.common.UserIds,
googleApiKey: Secret,
twitchCredentials: () => (String, String)
) extends Actor {
@ -132,7 +132,7 @@ final private class Streaming(
acc ::: result.streams(
keyword,
streamers,
alwaysFeatured().value.map(_.toLowerCase)
alwaysFeatured().value
)
)
else fuccess(acc)

View File

@ -60,7 +60,7 @@ object BuildSettings {
"-language:postfixOps",
"-Ymacro-annotations",
// Warnings as errors!
"-Xfatal-warnings",
// "-Xfatal-warnings",
// Linting options
"-unchecked",
"-Xcheckinit",