From 2fab4f0940de5b579ff58ccd5f523c74977d2396 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 2 Mar 2021 15:43:18 +1100 Subject: [PATCH] Use sentAt as lastJoinedTimestamp when we get a new closed group This is to make sure we do not drop group updates between the message adding us and now(). We only have to drop messages before we were added to the group, which is the sent timestamp --- ts/receiver/closedGroups.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ts/receiver/closedGroups.ts b/ts/receiver/closedGroups.ts index b0d2e5dc2..eebc7c0b9 100644 --- a/ts/receiver/closedGroups.ts +++ b/ts/receiver/closedGroups.ts @@ -203,7 +203,7 @@ export async function handleNewClosedGroup( // Enable typing: maybeConvo.set('isKickedFromGroup', false); maybeConvo.set('left', false); - maybeConvo.set('lastJoinedTimestamp', Date.now()); + maybeConvo.set('lastJoinedTimestamp', _.toNumber(envelope.timestamp)); } else { log.warn( 'Ignoring a closed group message of type NEW: the conversation already exists' @@ -242,6 +242,12 @@ export async function handleNewClosedGroup( // the sending pipeline needs to know from GroupUtils when a message is for a medium group await ClosedGroup.updateOrCreateClosedGroup(groupDetails); + // ClosedGroup.updateOrCreateClosedGroup will mark the activeAt to Date.now if it's active + // But we need to override this value with the sent timestamp of the message creating this group for us. + // Having that timestamp set will allow us to pickup incoming group update which were sent between + // envelope.timestamp and Date.now(). And we need to listen to those (some might even remove us) + convo.set('lastJoinedTimestamp', _.toNumber(envelope.timestamp)); + await convo.commit(); // sanity checks validate this // tslint:disable: no-non-null-assertion