feat: starting member left admin handling functionality

This commit is contained in:
0x330a 2023-11-30 17:16:23 +11:00
parent 253788b4ed
commit ecc75dfeed
No known key found for this signature in database
GPG key ID: 267811D6E6A2698C
3 changed files with 21 additions and 1 deletions

View file

@ -1616,6 +1616,25 @@ open class Storage(
keys.free()
}
override fun handleMemberLeft(message: GroupUpdated, closedGroupId: SessionId) {
val userGroups = configFactory.userGroups ?: return
val closedGroup = userGroups.getClosedGroup(closedGroupId.hexString()) ?: return
if (closedGroup.hasAdminKey()) {
// re-key and do a new config removing the previous member
val info = configFactory.getGroupInfoConfig(closedGroupId) ?: return
val members = configFactory.getGroupMemberConfig(closedGroupId) ?: return
val keys = configFactory.getGroupKeysConfig(closedGroupId, info, members, free = false) ?: return
members.erase(message.sender!!)
keys.rekey(info, members)
val
}
insertGroupInfoChange(message, closedGroupId)
}
override fun leaveGroup(groupSessionId: String) {
val closedGroupId = SessionId.from(groupSessionId)
val message = GroupUpdated(

View file

@ -172,6 +172,7 @@ interface StorageProtocol {
fun promoteMember(groupSessionId: String, promotions: Array<String>)
fun removeMember(groupSessionId: String, removedMembers: Array<String>, fromDelete: Boolean = false)
fun handlePromoted(keyPair: KeyPair)
fun handleMemberLeft(message: GroupUpdated, closedGroupId: SessionId)
fun leaveGroup(groupSessionId: String)
// Groups

View file

@ -557,7 +557,7 @@ private fun handleMemberChange(message: GroupUpdated, closedGroup: SessionId) {
private fun handleMemberLeft(message: GroupUpdated, closedGroup: SessionId) {
val storage = MessagingModuleConfiguration.shared.storage
storage.insertGroupInfoChange(message, closedGroup)
storage.handleMemberLeft(message, closedGroup)
}
private fun handleGroupInfoChange(message: GroupUpdated, closedGroup: SessionId) {