don't show zombie members in group remove updates

This commit is contained in:
Brice-W 2021-04-26 16:33:54 +10:00
parent 6a32fabda5
commit d4aaebd0a9
2 changed files with 20 additions and 9 deletions

View File

@ -437,6 +437,7 @@ private fun MessageReceiver.handleClosedGroupMembersAdded(message: ClosedGroupCo
val updateMembers = kind.members.map { it.toByteArray().toHexString() } val updateMembers = kind.members.map { it.toByteArray().toHexString() }
val newMembers = members + updateMembers val newMembers = members + updateMembers
storage.updateMembers(groupID, newMembers.map { Address.fromSerialized(it) }) storage.updateMembers(groupID, newMembers.map { Address.fromSerialized(it) })
// Notify the user // Notify the user
if (userPublicKey == senderPublicKey) { if (userPublicKey == senderPublicKey) {
// sender is a linked device // sender is a linked device
@ -526,12 +527,17 @@ private fun MessageReceiver.handleClosedGroupMembersRemoved(message: ClosedGroup
else SignalServiceGroup.Type.MEMBER_REMOVED else SignalServiceGroup.Type.MEMBER_REMOVED
// Notify the user // Notify the user
if (userPublicKey == senderPublicKey) { // we don't display zombie members in the notification as users have already been notified when those members left
// sender is a linked device val notificationMembers = updateMembers.minus(zombies)
val threadID = storage.getOrCreateThreadIdFor(Address.fromSerialized(groupID)) if (notificationMembers.isNotEmpty()) {
storage.insertOutgoingInfoMessage(context, groupID, type, name, updateMembers, admins, threadID, message.sentTimestamp!!) // no notification to display when only zombies have been removed
} else { if (userPublicKey == senderPublicKey) {
storage.insertIncomingInfoMessage(context, senderPublicKey, groupID, type, name, updateMembers, admins, message.sentTimestamp!!) // sender is a linked device
val threadID = storage.getOrCreateThreadIdFor(Address.fromSerialized(groupID))
storage.insertOutgoingInfoMessage(context, groupID, type, name, notificationMembers, admins, threadID, message.sentTimestamp!!)
} else {
storage.insertIncomingInfoMessage(context, senderPublicKey, groupID, type, name, notificationMembers, admins, message.sentTimestamp!!)
}
} }
} }

View File

@ -201,9 +201,14 @@ fun MessageSender.removeMembers(groupPublicKey: String, membersToRemove: List<St
// Notify the user // Notify the user
// Insert an outgoing notification // Insert an outgoing notification
val infoType = SignalServiceGroup.Type.MEMBER_REMOVED // we don't display zombie members in the notification as users have already been notified when those members left
val threadID = storage.getOrCreateThreadIdFor(Address.fromSerialized(groupID)) val notificationMembers = membersToRemove.minus(oldZombies)
storage.insertOutgoingInfoMessage(context, groupID, infoType, name, membersToRemove, admins, threadID, sentTime) if (notificationMembers.isNotEmpty()) {
// no notification to display when only zombies have been removed
val infoType = SignalServiceGroup.Type.MEMBER_REMOVED
val threadID = storage.getOrCreateThreadIdFor(Address.fromSerialized(groupID))
storage.insertOutgoingInfoMessage(context, groupID, infoType, name, notificationMembers, admins, threadID, sentTime)
}
} }
fun MessageSender.leave(groupPublicKey: String, notifyUser: Boolean = true): Promise<Unit, Exception> { fun MessageSender.leave(groupPublicKey: String, notifyUser: Boolean = true): Promise<Unit, Exception> {