API for individual threads now working
This commit is contained in:
parent
7a60a70221
commit
2d99ad4c46
|
@ -38,7 +38,7 @@ object Message extends LilaController {
|
|||
html.message.thread(thread, forms.post, blocked)
|
||||
}
|
||||
} map NoCache,
|
||||
api = _ => OptionFuOk(api.thread(id, me)) { thread => Env.message.jsonView.thread(thread) }
|
||||
api = _ => JsonOptionFuOk(api.thread(id, me)) { thread => Env.message.jsonView.thread(thread) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,10 +30,19 @@ final class JsonView() {
|
|||
"updateAt" -> thread.updatedAt
|
||||
)
|
||||
|
||||
def thread(thread: Thread): Fu[Result] =
|
||||
Fu {
|
||||
Ok(
|
||||
Json.obj()
|
||||
def thread(thread: Thread): Fu[JsValue] =
|
||||
fuccess (
|
||||
Json.obj(
|
||||
"id" -> thread.id,
|
||||
"name" -> thread.name,
|
||||
"posts" -> thread.posts.map { post => threadPost(thread, post)}
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
def threadPost(thread: Thread, post: Post): JsValue =
|
||||
Json.obj(
|
||||
"sender" -> thread.senderOf(post),
|
||||
"receiver" -> thread.receiverOf(post),
|
||||
"text" -> post.text
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue