Add study chat data to mobile api
This commit is contained in:
parent
0564d0289e
commit
a4107d94fc
|
@ -148,10 +148,19 @@ object Study extends LilaController {
|
|||
sVersion <- env.version(sc.study.id)
|
||||
streams <- streamsOf(sc.study)
|
||||
} yield Ok(html.study.show(sc.study, data, chat, sVersion, streams)),
|
||||
api = _ => Ok(Json.obj(
|
||||
"study" -> data.study,
|
||||
"analysis" -> data.analysis
|
||||
)).fuccess
|
||||
api = _ => chatOf(sc.study).map { chatOpt =>
|
||||
Ok(
|
||||
Json.obj(
|
||||
"study" -> data.study.add("chat" -> chatOpt.map { c =>
|
||||
lila.chat.JsonView.mobile(
|
||||
chat = c.chat,
|
||||
writeable = ctx.userId.??(sc.study.canChat)
|
||||
)
|
||||
}),
|
||||
"analysis" -> data.analysis
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
} yield res
|
||||
}
|
||||
|
|
|
@ -18,6 +18,11 @@ object JsonView {
|
|||
"history" -> u.history
|
||||
)
|
||||
|
||||
def mobile(chat: AnyChat, writeable: Boolean = true) = Json.obj(
|
||||
"lines" -> apply(chat),
|
||||
"writeable" -> writeable
|
||||
)
|
||||
|
||||
implicit val chatIdWrites: Writes[Chat.Id] = stringIsoWriter(Chat.chatIdIso)
|
||||
|
||||
lazy val timeoutReasons = Json toJson ChatTimeout.Reason.all
|
||||
|
|
Loading…
Reference in a new issue