Forum Discussion
Thanks for your help, but let me clarify what I am asking.
We are utilizing the Community/Search/Messages api to get back a list of search results. When someone searches on the website and click on a link, it not only takes them to a linear version of the thread, but it also directs them to the correct page of the thread in order to view the message that matched their search results.
We are attempting to replicate this functionality within a tool on an internal system. Ideally, when a user clicks on one of the search results, they are directed to a page that renders a linear view of the thread and brings them directly to the page they need to be on to view the message that matched their search. As far as I can tell, there is no programmatic way to determine which number a message is in the linear view of a thread. That is what we need.
If you include the parameter restapi.response_style=view in the REST API URL, the results will include the URL for each message returned in the results.
For example, if you search Lithosphere:
http://lithosphere.lithium.com/restapi/vc/search/messages?q=test&restapi.response_style=view
The first message tag looks like this:
<message type="message" href="/messages/id/129079" view_href="http://lithosphere.lithium.com/t5/developers-discussion/Test-messages/m-p/129079#M4947">
The view_href URL should take you straight to the message, whichever page it is on.
- bdelaune_hp11 years agoContributor
Thanks, Nathan, and we are aware of this functionality, but we need the ability to show the thread within our tool without linking out to the website. The case we are using it in will not allow the users to actually go to the website (it is blocked on their machines). We need to replicate the same functionality as that view_href link within our own tool.
Does that make sense?
- YuriK11 years agoKhoros Expert
Hey Bdelaune,
If I'm not mistaken, you're trying to do is figure out the index of the message in a thread, so that you can figure out what page to pass into the /threads/linear call. Unfortunately, there is nothing out of the box that will do that at the moment. One of the reasons for this is that the index of the message would depend on how you're sorting the messages in a thread.
One way that you could get this information is to create an endpoint that will take in a message id and a thread id, and will page through the thread's results using AdamN's method and return the index of the message in the thread with your sorting algorithm, you can then use the index of the message to decide what page to retrieve from the /thread/linear call. However, this approach may not be performant enough for your needs, but since you're doing this for one message at a time only when the user clicks on a search result, it may be ok.
I would also suggest that you add a suggestion to the Lithium Ideas board to create an API that returns the index of a message within a thread that is sorted with a specific algorithm.
Hope this helps,
Yuri
Related Content
- 10 months ago
- 5 years ago
- 11 months ago
- 2 years ago