Hello I have used this https://rocket.chat/docs/developer-guides/rest-api/im/history for get unread message via rest API. Rocket.chat server version is 0.57.3 .
Example Call
1) https://rcserver.rocket.chat/api/v1/im.history?roomId=ByehQjC44FwMeiLbX?&unreads=true
2) https://rcserver.rocket.chat/api/v1/im.history?roomId=ByehQjC44FwMeiLbX?&unreads=โ+true
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(Constants.CONST_SITEURL);
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("X-Auth-Token", authToken);
client.DefaultRequestHeaders.Add("X-User-Id", userRcId);
HttpResponseMessage msgHistory = client.GetAsync(Constants.CONST_CHATHISTORY + userDetail.RC_RoomID + "&count=20&unreads=true").Result;
if (msgHistory.IsSuccessStatusCode)
{
using (HttpContent content = msgHistory.Content)
{
var result = content.ReadAsStringAsync();
value = JObject.Parse(result.Result);
}
directChatWindow = JsonConvert.DeserializeObject<DirectChatWindowBO>(value.ToString());
}
I have try to above link and code but it will not give any unread property in result
Example Result
{
"messages": [
{
"_id": "7e6691fc-16sdfd3-ecbfsd8-317a-4076bb307e5dfsfd-4564",
"rid": "CBsDHB7M8fsdfsdfN8G4X2BjsBDt5khnkenENacLN",
"msg": "hittti",
"ts": "2017-08-16T11:08:21.011Z",
"u": {
"_id": "CBsDHsdadsaB7M8N8G4X2Bj",
"username": "xyz",
"name": "xyz21"
},
"mentions": [],
"channels": [],
"_updatedAt": "2017-08-16T11:08:21.013Z"
},
{
"_id": "eaf75056-bcxcvxcv40c-4a68-0128-c40503289d60",
"rid": "CBsDHxcvB7M8cvxvxcvN8G4X2BjsBDt5kxcvhnkenENacLN",
"msg": "hi",
"ts": "2017-08-16T11:07:53.579Z",
"u": {
"_id": "CBsDHB7M8N8G4X2Bj",
"username": "Abc",
"name": "Abc123 "
},
"mentions": [],
"channels": [],
"_updatedAt": "2017-08-16T11:07:53.583Z"
}]
}
Please help me out.
Thank You.
We aim to keep our Github issues for bugs and feature requests. This does not fit that criteria.
Please see our guidelines for support. If you feel like we are closing in error, please re-open and add additional details about the bug or feature request.
Reopening as this is actually a bug with the current channels.history api endpoint, the value is never being returned to the clients.
I have the same problem with version 0.59.3. I can't find the total of unreal messages. All I see is the unreadNotLoaded property and its value is always 0. I can't see what has been done in 4f3c9d4 to fix the unread issue. Maybe I'm missing something?
@mbouchard what's the full url you're calling?
I'm calling /api/v1/channels.history?roomName=general&unreads=true&oldest=2017-01-01. I think I don't really understand what the value of unreadNotLoaded means. I've been able to get something else than 0, but the value is not what I expect. I expect it to be the same as the number of unread messages I see in the Rocket.Chat app, but it's not the case. And if I use the count param, the value of unreadNotLoaded is changing, which I don't understand neither.
Hi @mbouchard , the unreadNotLoaded returns the amount of messages you have unread and server didn't returned on that request. It's not the total amount.
To get the total amount we verify if the unreadNotLoaded is greater then 0 the unread count will be the unreadNotLoaded + request.count, if not we need to check the subscription.ls property, that is a timestamp, sort the messages by ts and then count the messages where ts is greater than subscription.ls. That is the current way to do it.
@mbouchard graywolf336 I'm calling "/api/v1/im.history?roomId=MLtBizp6jZT6w5LmqXrJK2GRbJBPPKSYPm&unreads=true", but it return unreadNotLoaded = 0; Which is not right. Please help me ASAP.
@shreekarade I never managed to get the correct number of unread messages with that method and I didn't have any time left to achieve it.
Hi Team,
We have any plan to get unread messages for particular USERS
Most helpful comment
Hi Team,
We have any plan to get unread messages for particular USERS