Akenefick
3 years agoGenius
Get Latest Reply to Each Conversation Returned by Messages LiQL Query
I have recreated our message list with various filters. I am using a JSON messages query with a replies subquery. I am getting messages for the board with depth=0 (topics) sorted by conversation.last_post_time.
For example:
<#assign solvedMessageCall = restBuilder()
.method("POST")
.path("/search")
.body(
[
{
"messages": {
"fields": [
"author.avatar.message",
"author.login",
"author.view_href",
"author.rank.name",
"author.rank.icon_right",
"author.rank.color",
"author.rank.bold",
"subject",
"post_time",
"post_time_friendly",
"view_href",
"replies.count(*)",
"metrics.views",
"user_context.read",
"replies"
],
"constraints": [
{
"board.id": "${boardId}",
"depth":0,
"conversation.solved": true
}
],
"sorts": [
"conversation.last_post_time desc"
],
"limit":results_list_size,
"offset":offSet,
"subQueries": {
"replies": {
"fields": [
"author.login",
"author.view_href",
"author.rank.name",
"author.rank.icon_right",
"author.rank.color",
"author.rank.bold",
"post_time"
],
"limit": 1
}
}
}
}
]
) />
Because I can sort by conversation.last_post_time the order is correct and matches the out of the box message list. So far so good.
However, I also want to show the latest reply to the conversation like this:
The replies subquery is giving me the latest reply to the topic post, not necessarily the latest reply to the conversation which might be a reply to a reply. The out of the box message list shows the correct latest reply. Is there any way to recreate this without having to make additional API calls?
Thanks!
Sign in to react to this post