From 2f2dfb98d3b19f2ed8774debd82dd3f0b2f0682a Mon Sep 17 00:00:00 2001 From: Marcos Defendi Date: Thu, 8 Nov 2018 10:34:11 -0200 Subject: [PATCH 1/2] Improve unreads and unreadsFrom response, prevent it to be equal null --- packages/rocketchat-api/server/v1/groups.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/rocketchat-api/server/v1/groups.js b/packages/rocketchat-api/server/v1/groups.js index 5a125fb01d31..be03cba850a8 100644 --- a/packages/rocketchat-api/server/v1/groups.js +++ b/packages/rocketchat-api/server/v1/groups.js @@ -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, lm); + unreadsFrom = subscription.ls || subscription.ts; userMentions = subscription.userMentions; joined = true; } From a99e6b7ee0efd5b5e16ef98b2e13e7facf7848b6 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Tue, 20 Nov 2018 20:58:52 -0200 Subject: [PATCH 2/2] Add timestamp or last seen in groups.counter Co-Authored-By: MarcosSpessatto --- packages/rocketchat-api/server/v1/groups.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rocketchat-api/server/v1/groups.js b/packages/rocketchat-api/server/v1/groups.js index be03cba850a8..fc5430c1f6ce 100644 --- a/packages/rocketchat-api/server/v1/groups.js +++ b/packages/rocketchat-api/server/v1/groups.js @@ -151,7 +151,7 @@ RocketChat.API.v1.addRoute('groups.counters', { authRequired: true }, { const lm = room.lm ? room.lm : room._updatedAt; if (typeof subscription !== 'undefined' && subscription.open) { - unreads = RocketChat.models.Messages.countVisibleByRoomIdBetweenTimestampsInclusive(subscription.rid, subscription.ls, lm); + unreads = RocketChat.models.Messages.countVisibleByRoomIdBetweenTimestampsInclusive(subscription.rid, (subscription.ls || subscription.ts), lm); unreadsFrom = subscription.ls || subscription.ts; userMentions = subscription.userMentions; joined = true;