Forum Discussion

allensmith81's avatar
7 years ago

Using user_context.read as a constraint on messages collection

Hi all,

 

We are wanting to use a Liql Query like 'Select * from messages where user_context.read = false and board.id='boardid''

 

Essentially what we want to do is be able to list only unread messages for the user in a give board but I cant find a way to do that, any suggestions?

11 Replies

  • DougS's avatar
    DougS
    Khoros Alumni (Retired)
    7 years ago

    Hi Allen,

    We don't currently have a way via the API to do look up messages that have been read by the current user in a given board. We do have a way in REST V1 to get a count of read messages for a given board (see the /boards/id/[id]/messages/read/count call), but no way in REST V2 or REST V1 to get only the unread messages in a board.

    To list only the unread messages for a given user in a custom component or endpoints, you would need to get the first set of messages for the given board and then check if the message has not already been read (by checking the user_context.read property). You'd need to keep track of how many unread messages have been processed and then make another call to get the next set, until the target number of messages you want to display has been met.

     

    -Doug