fix: open group avatar loop for open groups we have left

This commit is contained in:
0x330a 2023-05-23 15:30:40 +10:00
parent f91fc2503b
commit 1781d7e85f
No known key found for this signature in database
GPG Key ID: 267811D6E6A2698C
4 changed files with 8 additions and 17 deletions

View File

@ -245,10 +245,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
}
val recipient = Recipient.from(this, address, false)
threadId = storage.getOrCreateThreadIdFor(recipient.address)
// assume created thread
if (recipient.isContactRecipient && !recipient.isLocalNumber) {
storage.setRecipientApproved(recipient, true) // assume approved when we CREATE the thread, not send first message
}
}
} ?: finish()
}

View File

@ -5,7 +5,6 @@ import android.net.Uri
import network.loki.messenger.libsession_util.ConfigBase
import network.loki.messenger.libsession_util.ConfigBase.Companion.PRIORITY_HIDDEN
import network.loki.messenger.libsession_util.ConfigBase.Companion.PRIORITY_PINNED
import network.loki.messenger.libsession_util.ConfigBase.Companion.PRIORITY_VISIBLE
import network.loki.messenger.libsession_util.Contacts
import network.loki.messenger.libsession_util.ConversationVolatileConfig
import network.loki.messenger.libsession_util.UserGroupsConfig
@ -99,16 +98,6 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
val localUserAddress = getUserPublicKey() ?: return
if (!getRecipientApproved(address) && localUserAddress != address.serialize()) return // don't store unapproved / message requests
if (localUserAddress == address.serialize()) {
val userConfig = configFactory.user ?: return
if (userConfig.getNtsPriority() == PRIORITY_HIDDEN) {
// if it's hidden set it visible, otherwise it's pinned so don't change
userConfig.setNtsPriority(PRIORITY_VISIBLE)
DatabaseComponent.get(context).threadDatabase().setHasSent(threadId, true)
}
return
}
val volatile = configFactory.convoVolatile ?: return
if (address.isGroup) {
val groups = configFactory.userGroups ?: return
@ -139,6 +128,7 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
} else {
val userProfile = configFactory.user ?: return
userProfile.setNtsPriority(ConfigBase.PRIORITY_VISIBLE)
DatabaseComponent.get(context).threadDatabase().setHasSent(threadId, true)
}
val newVolatileParams = volatile.getOrConstructOneToOne(address.serialize())
volatile.set(newVolatileParams)

View File

@ -41,7 +41,12 @@ object OpenGroupManager {
if (isPolling) { return }
isPolling = true
val storage = MessagingModuleConfiguration.shared.storage
val servers = storage.getAllOpenGroups().values.map { it.server }.toSet()
val (serverGroups, toDelete) = storage.getAllOpenGroups().values.partition { storage.getThreadId(it) != null }
toDelete.forEach { openGroup ->
delete(openGroup.server, openGroup.room, MessagingModuleConfiguration.shared.context)
}
val servers = serverGroups.map { it.server }.toSet()
servers.forEach { server ->
pollers[server]?.stop() // Shouldn't be necessary
val poller = OpenGroupPoller(server, executorService)

View File

@ -20,7 +20,7 @@ class GroupAvatarDownloadJob(val server: String, val room: String, val imageId:
}
val storage = MessagingModuleConfiguration.shared.storage
val openGroup = storage.getOpenGroup(room, server)
if (openGroup == null) {
if (openGroup == null || storage.getThreadId(openGroup) == null) {
delegate?.handleJobFailedPermanently(this, dispatcherName, Exception("GroupAvatarDownloadJob openGroup is null"))
return
}