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
pull/1528/head
Audric Ackermann 4 years ago
parent a04bc0d225
commit 2fab4f0940

@ -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

Loading…
Cancel
Save