add `mustUpgrade: true` to /api/status when relevant - closes #3764 /cc @veloce

pull/3767/head
Thibault Duplessis 2017-10-31 10:38:23 -05:00
parent 0249aaa964
commit 0c291b37c0
2 changed files with 9 additions and 5 deletions

View File

@ -8,6 +8,7 @@ import scala.concurrent.duration._
import lila.api.Context
import lila.app._
import lila.common.PimpedJson._
import lila.common.{ HTTPRequest, IpAddress }
object Api extends LilaController {
@ -17,9 +18,9 @@ object Api extends LilaController {
private implicit val limitedDefault = Zero.instance[ApiResult](Limited)
private lazy val apiStatusResponse = {
private lazy val apiStatusJson = {
val api = lila.api.Mobile.Api
Ok(Json.obj(
Json.obj(
"api" -> Json.obj(
"current" -> api.currentVersion.value,
"olds" -> api.oldVersions.map { old =>
@ -30,11 +31,12 @@ object Api extends LilaController {
)
}
)
)) as JSON
)
}
val status = Action { req =>
apiStatusResponse
val mustUpgrade = get("v", req) exists lila.api.Mobile.AppVersion.mustUpgrade _
Ok(apiStatusJson.add("mustUpgrade", mustUpgrade)) as JSON
}
def user(name: String) = ApiRequest { implicit ctx =>

View File

@ -10,8 +10,10 @@ object Mobile {
object AppVersion {
def mustUpgrade(v: String) = mustUpgradeFromVersions(v)
// only call if a more recent version is available in both stores!
val callToUpgradeFromVersions = Set(
private val mustUpgradeFromVersions = Set(
"5.1.0", "5.1.1"
)