2

I'm trying to get the numbers of direct unread messages in rocket.chat.

I'm on 0.53.0 and trying with /api/v1/im.history to get the numbers of unreads. If I set unreads to "true" I can't distinguish between read and unread.

What is the way to get the numbers of unread?

Plot Norris
  • 49
  • 1
  • 9

1 Answers1

3

When calling the /api/v1/im.history if you set unreads to true you should have 3 properties on the object returned:

  • messages
  • firstUnread
  • unreadNotLoaded

This will be the first message unread. You would need to then find all messages with a newer timestamp and that would be your unread messages.

Reference to the code generating this payload: https://github.com/RocketChat/Rocket.Chat/blob/0.53.0/packages/rocketchat-lib/server/methods/getChannelHistory.js#L72

Aaron Ogle
  • 558
  • 3
  • 14