This commit is contained in:
Niels Andriesse 2021-01-07 14:39:07 +11:00
parent 87724a7e3c
commit 28963e252e
3 changed files with 6 additions and 0 deletions

View File

@ -41,6 +41,10 @@ extension Storage {
(transaction as! YapDatabaseReadWriteTransaction).setObject(groupPublicKey, forKey: groupPublicKey, inCollection: Storage.closedGroupPublicKeyCollection)
}
public func removeClosedGroupPublicKey(_ groupPublicKey: String, using transaction: Any) {
(transaction as! YapDatabaseReadWriteTransaction).removeObject(forKey: groupPublicKey, inCollection: Storage.closedGroupPublicKeyCollection)
}
// MARK: - Ratchets

View File

@ -290,6 +290,7 @@ extension MessageReceiver {
let wasCurrentUserRemoved = !members.contains(userPublicKey)
if wasCurrentUserRemoved {
Storage.shared.removeAllClosedGroupEncryptionKeyPairs(for: groupPublicKey, using: transaction)
Storage.shared.removeClosedGroupPublicKey(groupPublicKey, using: transaction)
// Notify the PN server
let _ = PushNotificationAPI.performOperation(.unsubscribe, for: groupPublicKey, publicKey: userPublicKey)
}

View File

@ -84,6 +84,7 @@ extension MessageSender : SharedSenderKeysDelegate {
SNMessagingKitConfiguration.shared.storage.write { transaction in
// Remove the group private key and unsubscribe from PNs
Storage.shared.removeAllClosedGroupEncryptionKeyPairs(for: groupPublicKey, using: transaction)
Storage.shared.removeClosedGroupPublicKey(groupPublicKey, using: transaction)
let _ = PushNotificationAPI.performOperation(.unsubscribe, for: groupPublicKey, publicKey: userPublicKey)
}
}