fix: remove user notifications for leaving group to prevent synced device issues, don't create thread in messages for new closed groups, includei nactive groups in the deletion queries for merging group configs

This commit is contained in:
0x330a
2023-05-05 16:05:43 +10:00
parent a1ee4ccde6
commit d4d4f81c36
12 changed files with 17 additions and 24 deletions

View File

@@ -148,7 +148,7 @@ interface StorageProtocol {
fun setExpirationTimer(address: String, duration: Int)
// Groups
fun getAllGroups(): List<GroupRecord>
fun getAllGroups(includeInactive: Boolean): List<GroupRecord>
// Settings
fun setProfileSharing(address: Address, value: Boolean)

View File

@@ -78,7 +78,7 @@ class BatchMessageReceiveJob(
else { // message is control message otherwise
return when(message) {
is SharedConfigurationMessage -> false
is ClosedGroupControlMessage -> message.kind is ClosedGroupControlMessage.Kind.New
is ClosedGroupControlMessage -> false // message.kind is ClosedGroupControlMessage.Kind.New && !message.isSenderSelf
is DataExtractionNotification -> false
is MessageRequestResponse -> false
is ExpirationTimerUpdate -> false

View File

@@ -122,7 +122,7 @@ class ConfigurationMessage(var closedGroups: List<ClosedGroup>, var openGroups:
val displayName = TextSecurePreferences.getProfileName(context) ?: return null
val profilePicture = TextSecurePreferences.getProfilePictureURL(context)
val profileKey = ProfileKeyUtil.getProfileKey(context)
val groups = storage.getAllGroups()
val groups = storage.getAllGroups(includeInactive = false)
for (group in groups) {
if (group.isClosedGroup) {
if (!group.members.contains(Address.fromSerialized(storage.getUserPublicKey()!!))) continue

View File

@@ -426,7 +426,7 @@ object MessageSender {
@JvmStatic
fun send(message: Message, address: Address) {
val threadID = MessagingModuleConfiguration.shared.storage.getOrCreateThreadIdFor(address)
val threadID = MessagingModuleConfiguration.shared.storage.getThreadId(address)
message.threadID = threadID
val destination = Destination.from(address)
val job = MessageSendJob(message, destination)

View File

@@ -459,7 +459,7 @@ private fun ClosedGroupControlMessage.getPublicKey(): String = kind!!.let { when
private fun MessageReceiver.handleNewClosedGroup(message: ClosedGroupControlMessage) {
val kind = message.kind!! as? ClosedGroupControlMessage.Kind.New ?: return
val recipient = Recipient.from(MessagingModuleConfiguration.shared.context, Address.fromSerialized(message.sender!!), false)
if (!recipient.isApproved && !recipient.isLocalNumber) return
if (!recipient.isApproved && !recipient.isLocalNumber) return Log.e("Loki", "not accepting new closed group from unapproved recipient")
val groupPublicKey = kind.publicKey.toByteArray().toHexString()
val members = kind.members.map { it.toByteArray().toHexString() }
val admins = kind.admins.map { it.toByteArray().toHexString() }
@@ -758,12 +758,7 @@ private fun MessageReceiver.handleClosedGroupMemberLeft(message: ClosedGroupCont
storage.setZombieMembers(groupID, zombies.plus(senderPublicKey).map { Address.fromSerialized(it) })
}
// Notify the user
if (userLeft) {
val threadID = storage.getThreadId(Address.fromSerialized(groupID))
if (threadID != null) {
storage.insertOutgoingInfoMessage(context, groupID, SignalServiceGroup.Type.QUIT, name, members, admins, threadID, message.sentTimestamp!!)
}
} else {
if (!userLeft) {
storage.insertIncomingInfoMessage(context, senderPublicKey, groupID, SignalServiceGroup.Type.QUIT, name, members, admins, message.sentTimestamp!!)
}
}