optional tighter panic mode

This commit is contained in:
Thibault Duplessis 2017-11-10 10:34:57 -05:00
parent 7e9635ae66
commit c530e08812
2 changed files with 3 additions and 2 deletions

View file

@ -75,7 +75,7 @@ object Tournament extends LilaController {
private[controllers] def canHaveChat(tour: Tour)(implicit ctx: Context): Boolean = ctx.me ?? { u =>
if (ctx.kid) false
else if (tour.isPrivate) true
else Env.chat.panic allowed u
else Env.chat.panic.allowed(u, tighter = tour.variant == chess.variant.Antichess)
}
def show(id: String) = Open { implicit ctx =>

View file

@ -8,9 +8,10 @@ final class ChatPanic {
private var until: Option[DateTime] = none
def allowed(u: User) = !enabled || {
def allowed(u: User, tighter: Boolean): Boolean = !(enabled || tighter) || {
u.count.game > 10 && u.createdSinceDays(1)
}
def allowed(u: User): Boolean = allowed(u, false)
def enabled = until exists { d =>
(d isAfter DateTime.now) || {