remove chat from round API, ensure mobile BC
This commit is contained in:
parent
af08abcee3
commit
d027003957
|
@ -76,9 +76,13 @@ object Round extends LilaController with TheftPrevention {
|
|||
),
|
||||
api = apiVersion => {
|
||||
if (isTheft(pov)) fuccess(theftResponse)
|
||||
else Env.api.roundApi.player(pov, apiVersion).map { Ok(_) }
|
||||
.mon(_.http.response.player.mobile)
|
||||
}
|
||||
else Env.api.roundApi.player(pov, apiVersion) zip
|
||||
getPlayerChat(pov.game) map {
|
||||
case (data, chat) => Ok(chat.fold(data) { c =>
|
||||
data + ("chat" -> lila.chat.JsonView(c))
|
||||
})
|
||||
}
|
||||
}.mon(_.http.response.player.mobile)
|
||||
) map NoCache
|
||||
|
||||
def player(fullId: String) = Open { implicit ctx =>
|
||||
|
|
|
@ -30,7 +30,6 @@ final class Env(
|
|||
divider: lila.game.Divider,
|
||||
i18nKeys: lila.i18n.I18nKeys,
|
||||
prefApi: lila.pref.PrefApi,
|
||||
chatApi: lila.chat.ChatApi,
|
||||
historyApi: lila.history.HistoryApi,
|
||||
scheduler: lila.common.Scheduler) {
|
||||
|
||||
|
@ -168,7 +167,6 @@ final class Env(
|
|||
socketHub ? Ask(gameId, GetSocketStatus) mapTo manifest[SocketStatus]
|
||||
|
||||
lazy val jsonView = new JsonView(
|
||||
chatApi = chatApi,
|
||||
noteApi = noteApi,
|
||||
userJsonView = userJsonView,
|
||||
getSocketStatus = getSocketStatus,
|
||||
|
@ -229,7 +227,6 @@ object Env {
|
|||
divider = lila.game.Env.current.divider,
|
||||
i18nKeys = lila.i18n.Env.current.keys,
|
||||
prefApi = lila.pref.Env.current.api,
|
||||
chatApi = lila.chat.Env.current.api,
|
||||
historyApi = lila.history.Env.current.api,
|
||||
scheduler = lila.common.PlayApp.scheduler)
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ import chess.{ Color, Clock }
|
|||
import actorApi.SocketStatus
|
||||
|
||||
final class JsonView(
|
||||
chatApi: lila.chat.ChatApi,
|
||||
noteApi: NoteApi,
|
||||
userJsonView: lila.user.JsonView,
|
||||
getSocketStatus: String => Fu[SocketStatus],
|
||||
|
@ -41,9 +40,8 @@ final class JsonView(
|
|||
withBlurs: Boolean): Fu[JsObject] =
|
||||
getSocketStatus(pov.game.id) zip
|
||||
(pov.opponent.userId ?? UserRepo.byId) zip
|
||||
canTakeback(pov.game) zip
|
||||
getPlayerChat(pov.game, playerUser) map {
|
||||
case (((socket, opponentUser), takebackable), chat) =>
|
||||
canTakeback(pov.game) map {
|
||||
case ((socket, opponentUser), takebackable) =>
|
||||
import pov._
|
||||
Json.obj(
|
||||
"game" -> gameJson(game, initialFen),
|
||||
|
@ -112,13 +110,6 @@ final class JsonView(
|
|||
}
|
||||
},
|
||||
"confirmResign" -> (pref.confirmResign == Pref.ConfirmResign.YES).option(true)),
|
||||
"chat" -> chat.map { c =>
|
||||
JsArray(c.lines map {
|
||||
case l: lila.chat.UserLine => userLineWrites writes l
|
||||
case lila.chat.PlayerLine(color, text) =>
|
||||
Json.obj("c" -> color.name, "t" -> text)
|
||||
})
|
||||
},
|
||||
"possibleMoves" -> possibleMoves(pov),
|
||||
"possibleDrops" -> possibleDrops(pov),
|
||||
"takebackable" -> takebackable,
|
||||
|
@ -277,11 +268,6 @@ final class JsonView(
|
|||
"sd" -> h.sd)
|
||||
}
|
||||
|
||||
private def getPlayerChat(game: Game, forUser: Option[User]): Fu[Option[lila.chat.MixedChat]] =
|
||||
game.hasChat optionFu {
|
||||
chatApi.playerChat find game.id map (_ forUser forUser)
|
||||
}
|
||||
|
||||
private def getUsers(game: Game) = UserRepo.pair(
|
||||
game.whitePlayer.userId,
|
||||
game.blackPlayer.userId)
|
||||
|
|
Loading…
Reference in a new issue