How to get room's (direct chat) unread messages?

Hello,

I am developing an application using rocket.chat REST API and Realtime API, I would like to ask how to get room’s unread messages and how to mark messages as read? Now I’m fetching rooms using Realtime API Get Rooms method, it sends me rooms with last message, but I can’t figure it out how can I differentiate if a message is read or not and later on how to mark a message as read when a user will load the room’s history.

Thanks

Hi! Have you seen this thread on stack overflow?

not sure about the second question, about to mark as read. I’ll try to follow on that later on today.

1 Like

Thank you for response, yes I did, it doesn’t work. First of all it is related to channels (room type “c”) not direct chat (room type “d”).

And even when I’ve created testing channel for this endpoint it only returns an array of messages with success boolean and unreadNotLoaded which looks like that:

{
  messages: [...],
  success: true,
  unreadNotLoaded: 0,
}

so there is no firstUnread object :frowning:

When it comes to the second question, if there is a possibility to get “unread” messages, when they get “read” status? Is there some kind of endpoint to do it?

Ok! I’ll setup an environment here later on and will ask around with our devs about it. Hang tight.

1 Like

I know that /api/v1/im.history endpoint is for the direct messages, and /api/v1/channels.history endpoint is for the channels, but I don’t for example how can I find out which message is unread when a user logins to an account and the app displays him a list of users with their’s last message from Realtime API rooms/get method.

The rooms/get method sends me back the lastMessage, but I don’t know how can I find out if the message was read by the user before or not.

Thanks.

Hello, did you find the answer?

Hi! Sorry for the late response :frowning:

I think this is what you are looking for:

1 Like