Add current ban to account info

This commit is contained in:
Vincent Velociter 2018-04-27 14:42:02 +02:00
parent 3d17926481
commit 60b9e15b7d
2 changed files with 7 additions and 2 deletions

View file

@ -35,8 +35,9 @@ object Account extends LilaController {
relationEnv.api.countFollowing(me.id) zip relationEnv.api.countFollowing(me.id) zip
Env.pref.api.getPref(me) zip Env.pref.api.getPref(me) zip
lila.game.GameRepo.urgentGames(me) zip lila.game.GameRepo.urgentGames(me) zip
Env.challenge.api.countInFor.get(me.id) map { Env.challenge.api.countInFor.get(me.id) zip
case nbFollowers ~ nbFollowing ~ prefs ~ povs ~ nbChallenges => Env.playban.api.currentBan(me.id) map {
case nbFollowers ~ nbFollowing ~ prefs ~ povs ~ nbChallenges ~ playban =>
Env.current.system.lilaBus.publish(lila.user.User.Active(me), 'userActive) Env.current.system.lilaBus.publish(lila.user.User.Active(me), 'userActive)
Ok { Ok {
import lila.pref.JsonView._ import lila.pref.JsonView._
@ -48,6 +49,7 @@ object Account extends LilaController {
"nbChallenges" -> nbChallenges "nbChallenges" -> nbChallenges
).add("kid" -> me.kid) ).add("kid" -> me.kid)
.add("troll" -> me.troll) .add("troll" -> me.troll)
.add("playban" -> playban)
} }
} }
) )

View file

@ -1,5 +1,6 @@
package lila.playban package lila.playban
import play.api.libs.json._
import org.joda.time.DateTime import org.joda.time.DateTime
case class UserRecord( case class UserRecord(
@ -63,6 +64,8 @@ case class TempBan(
} }
object TempBan { object TempBan {
implicit val tempbanWrites = Json.writes[TempBan]
private def make(minutes: Int) = TempBan( private def make(minutes: Int) = TempBan(
DateTime.now, DateTime.now,
minutes atMost 48 * 60 minutes atMost 48 * 60