/api/board/game/{id}/chat endpoint to fetch the game chat - for #9613
parent
4fcc2e7b2f
commit
3efbcbe28e
|
@ -66,7 +66,7 @@ final class PlayApi(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def boardCommand(cmd: String) =
|
def boardCommandPost(cmd: String) =
|
||||||
ScopedBody(_.Board.Play) { implicit req => me =>
|
ScopedBody(_.Board.Play) { implicit req => me =>
|
||||||
impl.command(me, cmd)(WithPovAsBoard)
|
impl.command(me, cmd)(WithPovAsBoard)
|
||||||
}
|
}
|
||||||
|
@ -119,6 +119,17 @@ final class PlayApi(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def boardCommandGet(cmd: String) =
|
||||||
|
ScopedBody(_.Board.Play) { implicit req => me =>
|
||||||
|
cmd.split('/') match {
|
||||||
|
case Array("game", id, "chat") =>
|
||||||
|
WithPovAsBoard(id, me) { pov =>
|
||||||
|
env.chat.api.userChat.find(lila.chat.Chat.Id(pov.game.id)) map
|
||||||
|
lila.chat.JsonView.boardApi map JsonOk
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// utils
|
// utils
|
||||||
|
|
||||||
private def toResult(f: Funit): Fu[Result] = catchClientError(f inject jsonOkResult)
|
private def toResult(f: Funit): Fu[Result] = catchClientError(f inject jsonOkResult)
|
||||||
|
|
|
@ -691,7 +691,8 @@ GET /api/bot/online controllers.PlayApi.botOnlineApi
|
||||||
GET /api/board/game/stream/:id controllers.PlayApi.boardGameStream(id: String)
|
GET /api/board/game/stream/:id controllers.PlayApi.boardGameStream(id: String)
|
||||||
POST /api/board/game/:id/move/:uci controllers.PlayApi.boardMove(id: String, uci: String, offeringDraw: Option[Boolean] ?= None)
|
POST /api/board/game/:id/move/:uci controllers.PlayApi.boardMove(id: String, uci: String, offeringDraw: Option[Boolean] ?= None)
|
||||||
POST /api/board/seek controllers.Setup.boardApiHook
|
POST /api/board/seek controllers.Setup.boardApiHook
|
||||||
POST /api/board/*cmd controllers.PlayApi.boardCommand(cmd: String)
|
POST /api/board/*cmd controllers.PlayApi.boardCommandPost(cmd: String)
|
||||||
|
GET /api/board/*cmd controllers.PlayApi.boardCommandGet(cmd: String)
|
||||||
|
|
||||||
# Account
|
# Account
|
||||||
GET /account/passwd controllers.Account.passwd
|
GET /account/passwd controllers.Account.passwd
|
||||||
|
|
|
@ -30,6 +30,13 @@ object JsonView {
|
||||||
"writeable" -> writeable
|
"writeable" -> writeable
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def boardApi(chat: UserChat) = JsArray {
|
||||||
|
chat.lines collect {
|
||||||
|
case UserLine(name, _, _, text, troll, del) if !troll && !del =>
|
||||||
|
Json.obj("text" -> text, "user" -> name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
object writers {
|
object writers {
|
||||||
|
|
||||||
implicit val chatIdWrites: Writes[Chat.Id] = stringIsoWriter(Chat.chatIdIso)
|
implicit val chatIdWrites: Writes[Chat.Id] = stringIsoWriter(Chat.chatIdIso)
|
||||||
|
|
Loading…
Reference in New Issue