better report user bot upgrade error
This commit is contained in:
parent
30bf322e5c
commit
51b34a15da
|
@ -38,7 +38,10 @@ final class PlayApi(
|
|||
case _ =>
|
||||
env.user.repo.setBot(me) >>
|
||||
env.pref.api.setBot(me) >>-
|
||||
env.user.lightUserApi.invalidate(me.id) pipe toResult
|
||||
env.user.lightUserApi.invalidate(me.id) pipe
|
||||
toResult recover {
|
||||
case lila.base.LilaInvalid(msg) => BadRequest(jsonError(msg))
|
||||
}
|
||||
}
|
||||
case _ => impl.command(me, cmd)(WithPovAsBot)
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ trait LilaException extends Exception {
|
|||
override def toString = message
|
||||
}
|
||||
|
||||
case class LilaInvalid(message: String) extends LilaException
|
||||
|
||||
object LilaException extends scalaz.syntax.ToShowOps {
|
||||
|
||||
def apply(msg: String) =
|
||||
|
|
|
@ -484,7 +484,8 @@ final class UserRepo(val coll: Coll)(implicit ec: scala.concurrent.ExecutionCont
|
|||
def isManaged(id: ID): Fu[Boolean] = email(id).dmap(_.exists(_.isNoReply))
|
||||
|
||||
def setBot(user: User): Funit =
|
||||
if (user.count.game > 0) fufail("You already have games played. Make a new account.")
|
||||
if (user.count.game > 0)
|
||||
fufail(lila.base.LilaInvalid("You already have games played. Make a new account."))
|
||||
else coll.updateField($id(user.id), F.title, Title.BOT).void
|
||||
|
||||
private def botSelect(v: Boolean) =
|
||||
|
|
Loading…
Reference in a new issue