mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 11:05:25 +00:00
Updated logic to delete legacy groups when kicked/left
This commit is contained in:
parent
75fb714cbc
commit
422f53c86a
@ -234,7 +234,7 @@ fun MessageSender.leave(groupPublicKey: String, notifyUser: Boolean = true): Pro
|
|||||||
storage.insertOutgoingInfoMessage(context, groupID, infoType, name, updatedMembers, admins, threadID, sentTime)
|
storage.insertOutgoingInfoMessage(context, groupID, infoType, name, updatedMembers, admins, threadID, sentTime)
|
||||||
}
|
}
|
||||||
// Remove the group private key and unsubscribe from PNs
|
// Remove the group private key and unsubscribe from PNs
|
||||||
MessageReceiver.disableLocalGroupAndUnsubscribe(groupPublicKey, groupID, userPublicKey)
|
MessageReceiver.disableLocalGroupAndUnsubscribe(groupPublicKey, groupID, userPublicKey, true)
|
||||||
deferred.resolve(Unit)
|
deferred.resolve(Unit)
|
||||||
}.fail {
|
}.fail {
|
||||||
storage.setActive(groupID, true)
|
storage.setActive(groupID, true)
|
||||||
|
@ -692,7 +692,8 @@ private fun MessageReceiver.handleClosedGroupMembersRemoved(message: ClosedGroup
|
|||||||
val wasCurrentUserRemoved = userPublicKey in removedMembers
|
val wasCurrentUserRemoved = userPublicKey in removedMembers
|
||||||
// Admin should send a MEMBERS_LEFT message but handled here just in case
|
// Admin should send a MEMBERS_LEFT message but handled here just in case
|
||||||
if (didAdminLeave || wasCurrentUserRemoved) {
|
if (didAdminLeave || wasCurrentUserRemoved) {
|
||||||
disableLocalGroupAndUnsubscribe(groupPublicKey, groupID, userPublicKey)
|
disableLocalGroupAndUnsubscribe(groupPublicKey, groupID, userPublicKey, true)
|
||||||
|
return
|
||||||
} else {
|
} else {
|
||||||
storage.updateMembers(groupID, newMembers.map { Address.fromSerialized(it) })
|
storage.updateMembers(groupID, newMembers.map { Address.fromSerialized(it) })
|
||||||
// Update zombie members
|
// Update zombie members
|
||||||
@ -746,7 +747,11 @@ private fun MessageReceiver.handleClosedGroupMemberLeft(message: ClosedGroupCont
|
|||||||
val updatedMemberList = members - senderPublicKey
|
val updatedMemberList = members - senderPublicKey
|
||||||
val userLeft = (userPublicKey == senderPublicKey)
|
val userLeft = (userPublicKey == senderPublicKey)
|
||||||
if (didAdminLeave || userLeft) {
|
if (didAdminLeave || userLeft) {
|
||||||
disableLocalGroupAndUnsubscribe(groupPublicKey, groupID, userPublicKey)
|
disableLocalGroupAndUnsubscribe(groupPublicKey, groupID, userPublicKey, delete = userLeft)
|
||||||
|
|
||||||
|
if (userLeft) {
|
||||||
|
return
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
storage.updateMembers(groupID, updatedMemberList.map { Address.fromSerialized(it) })
|
storage.updateMembers(groupID, updatedMemberList.map { Address.fromSerialized(it) })
|
||||||
// Update zombie members
|
// Update zombie members
|
||||||
@ -774,7 +779,7 @@ private fun isValidGroupUpdate(group: GroupRecord, sentTimestamp: Long, senderPu
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun MessageReceiver.disableLocalGroupAndUnsubscribe(groupPublicKey: String, groupID: String, userPublicKey: String) {
|
fun MessageReceiver.disableLocalGroupAndUnsubscribe(groupPublicKey: String, groupID: String, userPublicKey: String, delete: Boolean) {
|
||||||
val storage = MessagingModuleConfiguration.shared.storage
|
val storage = MessagingModuleConfiguration.shared.storage
|
||||||
storage.removeClosedGroupPublicKey(groupPublicKey)
|
storage.removeClosedGroupPublicKey(groupPublicKey)
|
||||||
// Remove the key pairs
|
// Remove the key pairs
|
||||||
@ -786,5 +791,11 @@ fun MessageReceiver.disableLocalGroupAndUnsubscribe(groupPublicKey: String, grou
|
|||||||
PushNotificationAPI.performOperation(PushNotificationAPI.ClosedGroupOperation.Unsubscribe, groupPublicKey, userPublicKey)
|
PushNotificationAPI.performOperation(PushNotificationAPI.ClosedGroupOperation.Unsubscribe, groupPublicKey, userPublicKey)
|
||||||
// Stop polling
|
// Stop polling
|
||||||
ClosedGroupPollerV2.shared.stopPolling(groupPublicKey)
|
ClosedGroupPollerV2.shared.stopPolling(groupPublicKey)
|
||||||
|
|
||||||
|
if (delete) {
|
||||||
|
val threadId = storage.getOrCreateThreadIdFor(Address.fromSerialized(groupID))
|
||||||
|
storage.cancelPendingMessageSendJobs(threadId)
|
||||||
|
storage.deleteConversation(threadId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
Loading…
Reference in New Issue
Block a user