mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-23 02:56:21 +00:00
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:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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!!)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user