diff --git a/app/controllers/Round.scala b/app/controllers/Round.scala index ec26e24575..a23c7e031c 100644 --- a/app/controllers/Round.scala +++ b/app/controllers/Round.scala @@ -145,29 +145,29 @@ object Round extends LilaController with TheftPrevention { def watch(pov: Pov, userTv: Option[UserModel] = None)(implicit ctx: Context): Fu[Result] = negotiate( - html = if (pov.game.replayable) Analyse.replay(pov, userTv = userTv) - else if (pov.game.joinable) join(pov) - else ctx.userId.flatMap(pov.game.playerByUserId) ifTrue pov.game.playable match { - case Some(player) => renderPlayer(pov withColor player.color) - case None if HTTPRequest.isHuman(ctx.req) => - if (getBool("sudo") && isGranted(_.SuperAdmin)) - Redirect(routes.Round.player(pov.fullId)).fuccess - else myTour(pov.game.tournamentId, false) zip - (pov.game.simulId ?? Env.simul.repo.find) zip - Env.relay.api.round(pov.game) zip - Env.game.crosstableApi(pov.game) zip - Env.api.roundApi.watcher(pov, lila.api.Mobile.Api.currentVersion, tv = none) map { - case ((((tour, simul), relay), crosstable), data) => - Ok(html.round.watcher(pov, data, tour, simul, relay, crosstable, userTv = userTv)) - } - case _ => // web crawlers don't need the full thing - GameRepo.initialFen(pov.game.id) zip - Env.game.crosstableApi(pov.game) map { - case (initialFen, crosstable) => - val pgn = Env.api.pgnDump(pov.game, initialFen) - Ok(html.round.watcherBot(pov, initialFen, pgn, crosstable)) - } - }, + html = + if (getBool("sudo") && isGranted(_.SuperAdmin)) Redirect(routes.Round.player(pov.fullId)).fuccess + else if (pov.game.replayable) Analyse.replay(pov, userTv = userTv) + else if (pov.game.joinable) join(pov) + else ctx.userId.flatMap(pov.game.playerByUserId) ifTrue pov.game.playable match { + case Some(player) => renderPlayer(pov withColor player.color) + case None if HTTPRequest.isHuman(ctx.req) => + myTour(pov.game.tournamentId, false) zip + (pov.game.simulId ?? Env.simul.repo.find) zip + Env.relay.api.round(pov.game) zip + Env.game.crosstableApi(pov.game) zip + Env.api.roundApi.watcher(pov, lila.api.Mobile.Api.currentVersion, tv = none) map { + case ((((tour, simul), relay), crosstable), data) => + Ok(html.round.watcher(pov, data, tour, simul, relay, crosstable, userTv = userTv)) + } + case _ => // web crawlers don't need the full thing + GameRepo.initialFen(pov.game.id) zip + Env.game.crosstableApi(pov.game) map { + case (initialFen, crosstable) => + val pgn = Env.api.pgnDump(pov.game, initialFen) + Ok(html.round.watcherBot(pov, initialFen, pgn, crosstable)) + } + }, api = apiVersion => Env.api.roundApi.watcher(pov, apiVersion, tv = none) map { Ok(_) } ) map NoCache