MobileApi versioning
This commit is contained in:
parent
e11bf09137
commit
7149460818
|
@ -63,7 +63,7 @@ object Analyse extends LilaController {
|
|||
if (HTTPRequest.isBot(ctx.req)) divider.empty
|
||||
else divider(pov.game, initialFen)
|
||||
val pgn = Env.game.pgnDump(pov.game, initialFen)
|
||||
Env.api.roundApi.watcher(pov, Env.api.version, tv = none, analysis.map(pgn -> _), initialFen = initialFen.some) map { data =>
|
||||
Env.api.roundApi.watcher(pov, lila.api.MobileApi.currentVersion, tv = none, analysis.map(pgn -> _), initialFen = initialFen.some) map { data =>
|
||||
Ok(html.analyse.replay(
|
||||
pov,
|
||||
data,
|
||||
|
|
|
@ -56,7 +56,7 @@ object Round extends LilaController with TheftPrevention {
|
|||
Env.game.crosstableApi(pov.game) zip
|
||||
(!pov.game.isTournament ?? otherPovs(pov.gameId)) flatMap {
|
||||
case ((tour, crosstable), playing) =>
|
||||
Env.api.roundApi.player(pov, Env.api.version, playing) map { data =>
|
||||
Env.api.roundApi.player(pov, lila.api.MobileApi.currentVersion, playing) map { data =>
|
||||
Ok(html.round.player(pov, data, tour = tour, cross = crosstable, playing = playing))
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ object Round extends LilaController with TheftPrevention {
|
|||
case None =>
|
||||
(pov.game.tournamentId ?? TournamentRepo.byId) zip
|
||||
Env.game.crosstableApi(pov.game) zip
|
||||
Env.api.roundApi.watcher(pov, Env.api.version, tv = none) map {
|
||||
Env.api.roundApi.watcher(pov, lila.api.MobileApi.currentVersion, tv = none) map {
|
||||
case ((tour, crosstable), data) =>
|
||||
Ok(html.round.watcher(pov, data, tour, crosstable, userTv = userTv))
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ object Round extends LilaController with TheftPrevention {
|
|||
|
||||
private def join(pov: Pov)(implicit ctx: Context): Fu[Result] =
|
||||
GameRepo initialFen pov.game zip
|
||||
Env.api.roundApi.player(pov, Env.api.version, otherPovs = Nil) zip
|
||||
Env.api.roundApi.player(pov, lila.api.MobileApi.currentVersion, otherPovs = Nil) zip
|
||||
((pov.player.userId orElse pov.opponent.userId) ?? UserRepo.byId) map {
|
||||
case ((fen, data), opponent) => Ok(html.setup.join(
|
||||
pov, data, opponent, Env.setup.friendConfigMemo get pov.game.id, fen))
|
||||
|
|
|
@ -138,7 +138,7 @@ object Setup extends LilaController with TheftPrevention with play.api.http.Cont
|
|||
OptionFuResult(GameRepo pov fullId) { pov =>
|
||||
pov.game.started.fold(
|
||||
Redirect(routes.Round.player(pov.fullId)).fuccess,
|
||||
Env.api.roundApi.player(pov, Env.api.version, otherPovs = Nil) zip
|
||||
Env.api.roundApi.player(pov, lila.api.MobileApi.currentVersion, otherPovs = Nil) zip
|
||||
(userId ?? UserRepo.named) flatMap {
|
||||
case (data, user) => PreventTheft(pov) {
|
||||
Ok(html.setup.await(
|
||||
|
|
|
@ -36,7 +36,7 @@ object Tv extends LilaController {
|
|||
private def lichessTv(implicit ctx: Context) = OptionFuResult(Env.tv.featured.one) { game =>
|
||||
val flip = getBool("flip")
|
||||
val pov = flip.fold(Pov second game, Pov first game)
|
||||
Env.api.roundApi.watcher(pov, Env.api.version, tv = flip.some) zip
|
||||
Env.api.roundApi.watcher(pov, lila.api.MobileApi.currentVersion, tv = flip.some) zip
|
||||
(GameRepo onTv 10) zip
|
||||
Env.game.crosstableApi(game) zip
|
||||
Env.tv.streamsOnAir zip
|
||||
|
|
|
@ -51,7 +51,7 @@ object Environment
|
|||
|
||||
def isProd = apiEnv.isProd
|
||||
|
||||
def apiVersion = apiEnv.version
|
||||
def apiVersion = lila.api.MobileApi.currentVersion
|
||||
|
||||
lazy val siteMenu = new lila.app.ui.SiteMenu(trans)
|
||||
|
||||
|
|
|
@ -36,8 +36,6 @@ final class Env(
|
|||
val PrismicApiUrl = config getString "prismic.api_url"
|
||||
val EditorAnimationDuration = config duration "editor.animation.duration"
|
||||
|
||||
val version = config getInt "api.version"
|
||||
|
||||
object Accessibility {
|
||||
val blindCookieName = config getString "accessibility.blind.cookie.name"
|
||||
val blindCookieMaxAge = config getInt "accessibility.blind.cookie.max_age"
|
||||
|
|
24
modules/api/src/main/MobileApi.scala
Normal file
24
modules/api/src/main/MobileApi.scala
Normal file
|
@ -0,0 +1,24 @@
|
|||
package lila.api
|
||||
|
||||
import org.joda.time.DateTime
|
||||
|
||||
object MobileApi {
|
||||
|
||||
case class Old(
|
||||
version: Int,
|
||||
// date when a newer version was released
|
||||
deprecatedAt: DateTime,
|
||||
// date when the server stops accepting requests
|
||||
unsupportedAt: DateTime)
|
||||
|
||||
def currentVersion = 1
|
||||
|
||||
def oldVersions: List[Old] = List(
|
||||
// old version 0 is just an example, so the list is never empty :)
|
||||
// nobody ever used version 0.
|
||||
Old(
|
||||
version = 0,
|
||||
deprecatedAt = new DateTime("2014-08-01"),
|
||||
unsupportedAt = new DateTime("2014-12-01"))
|
||||
)
|
||||
}
|
Loading…
Reference in a new issue