add support for watcher chat in mobile API

This commit is contained in:
Thibault Duplessis 2016-11-06 19:03:40 +01:00
parent b0153faf48
commit 5957a4d6ac

View file

@ -187,14 +187,19 @@ object Round extends LilaController with TheftPrevention {
Ok(html.round.watcherBot(pov, initialFen, pgn))
}
}.mon(_.http.response.watcher.website),
api = apiVersion =>
Env.api.roundApi.watcher(pov, apiVersion, tv = none) flatMap { json =>
pov.game.metadata.analysed.??(analyser get pov.game.id) map { analysis =>
Ok(analysis.fold(json) { a =>
json + ("analysis" -> lila.analyse.JsonView.mobile(pov.game, a))
})
}
api = apiVersion => for {
data <- Env.api.roundApi.watcher(pov, apiVersion, tv = none)
analysis <- pov.game.metadata.analysed.??(analyser get pov.game.id)
chat <- getWatcherChat(pov.game)
} yield {
val withChat = chat.fold(data) { c =>
data + ("chat" -> lila.chat.JsonView(c.chat))
}
val withAnalysis = analysis.fold(withChat) { a =>
withChat + ("analysis" -> lila.analyse.JsonView.mobile(pov.game, a))
}
Ok(withAnalysis)
}
) map NoCache
}