add `mustUpgrade: true` to /api/status when relevant - closes #3764 /cc @veloce
parent
0249aaa964
commit
0c291b37c0
|
@ -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 =>
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue