From a67195c6cfb2456ad50e8e8580890d53a9083d9b Mon Sep 17 00:00:00 2001 From: Harris Date: Wed, 9 Mar 2022 17:48:31 +1100 Subject: [PATCH] Treat first sync closed groups as base for restoring device (#855) * feat: only sync closed groups on initial sync * fix: flip first sync bit --- .../sending_receiving/ReceivedMessageHandler.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/ReceivedMessageHandler.kt b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/ReceivedMessageHandler.kt index 088e5932bd..baa95a875b 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/ReceivedMessageHandler.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/ReceivedMessageHandler.kt @@ -124,13 +124,18 @@ private fun handleConfigurationMessage(message: ConfigurationMessage) { && !TextSecurePreferences.shouldUpdateProfile(context, message.sentTimestamp!!)) return val userPublicKey = storage.getUserPublicKey() if (userPublicKey == null || message.sender != storage.getUserPublicKey()) return + + val firstTimeSync = !TextSecurePreferences.getConfigurationMessageSynced(context) + TextSecurePreferences.setConfigurationMessageSynced(context, true) TextSecurePreferences.setLastProfileUpdateTime(context, message.sentTimestamp!!) - val allClosedGroupPublicKeys = storage.getAllClosedGroupPublicKeys() - for (closedGroup in message.closedGroups) { - if (allClosedGroupPublicKeys.contains(closedGroup.publicKey)) continue - handleNewClosedGroup(message.sender!!, message.sentTimestamp!!, closedGroup.publicKey, closedGroup.name, - closedGroup.encryptionKeyPair!!, closedGroup.members, closedGroup.admins, message.sentTimestamp!!, closedGroup.expirationTimer) + if (firstTimeSync) { + val allClosedGroupPublicKeys = storage.getAllClosedGroupPublicKeys() + for (closedGroup in message.closedGroups) { + if (allClosedGroupPublicKeys.contains(closedGroup.publicKey)) continue + handleNewClosedGroup(message.sender!!, message.sentTimestamp!!, closedGroup.publicKey, closedGroup.name, + closedGroup.encryptionKeyPair!!, closedGroup.members, closedGroup.admins, message.sentTimestamp!!, closedGroup.expirationTimer) + } } val allV2OpenGroups = storage.getAllV2OpenGroups().map { it.value.joinURL } for (openGroup in message.openGroups) {