Skip to content

Commit

Permalink
[IMPROVE] Improve unreads and unreadsFrom response, prevent it to be …
Browse files Browse the repository at this point in the history
…equal null (#12563)

* Improve unreads and unreadsFrom response, prevent it to be equal null

* Add timestamp or last seen  in groups.counter

Co-Authored-By: MarcosSpessatto <marcos.defendi@ulbra.inf.br>
  • Loading branch information
MarcosSpessatto authored and rodrigok committed Nov 21, 2018
1 parent 9289e5b commit dc70e80
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/rocketchat-api/server/v1/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,8 @@ RocketChat.API.v1.addRoute('groups.counters', { authRequired: true }, {
const lm = room.lm ? room.lm : room._updatedAt;

if (typeof subscription !== 'undefined' && subscription.open) {
if (subscription.ls) {
unreads = RocketChat.models.Messages.countVisibleByRoomIdBetweenTimestampsInclusive(subscription.rid, subscription.ls, lm);
unreadsFrom = subscription.ls;
}
unreads = RocketChat.models.Messages.countVisibleByRoomIdBetweenTimestampsInclusive(subscription.rid, (subscription.ls || subscription.ts), lm);
unreadsFrom = subscription.ls || subscription.ts;
userMentions = subscription.userMentions;
joined = true;
}
Expand Down

0 comments on commit dc70e80

Please sign in to comment.