Forum Discussion

kandulmadhu's avatar
10 years ago

REST API for count of unread posts

Hi,

 

The following is the call for getting count of unread messages in a thread:

http://community.lithium.com/community-name/restapi/vc/threads/id/[id]/messages/unread/count

 

Similarly, is there any REST API call for getting count of unread posts in a particular category/board w.r.t. logged in user?

 

Thanks and regards,

Madhu

 

 

  • Hi kandulmadhu

     

    I haven't seen that one, but there is a call for # of messages read by the user. So you can subtract that from the total to get the unread count. I would suggest using a macro for this and caching the result for some time to avoid running too many calls.

     

    Thanks,

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)

    Hi kandulmadhu

     

    I haven't seen that one, but there is a call for # of messages read by the user. So you can subtract that from the total to get the unread count. I would suggest using a macro for this and caching the result for some time to avoid running too many calls.

     

    Thanks,

    • kandulmadhu's avatar
      kandulmadhu
      Advisor

      Hi PaoloT,

       

      I have used your logic for getting the count of unread posts in a board but I am getting negative values for some boards.

       

      The following are the REST calls I used:

      For total count: "/boards/id/board_id/posts/count"
      For read posts: "/boards/id/board_id/messages/read/count"

      Then unread = total - read

       

      Do you have any idea why am I getting negative values for unread posts for some boards?

      Any help would be appreciated.

       

      Thanks and regards,

      Madhu