diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index fe5d41af11..87c6b2392a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -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() } diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt index 0f944ede72..5989cfcc6b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt @@ -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) diff --git a/app/src/main/java/org/thoughtcrime/securesms/groups/OpenGroupManager.kt b/app/src/main/java/org/thoughtcrime/securesms/groups/OpenGroupManager.kt index a54ff7d056..df8897a6fe 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/groups/OpenGroupManager.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/groups/OpenGroupManager.kt @@ -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) diff --git a/libsession/src/main/java/org/session/libsession/messaging/jobs/GroupAvatarDownloadJob.kt b/libsession/src/main/java/org/session/libsession/messaging/jobs/GroupAvatarDownloadJob.kt index 7ce995195f..f0831b8bb6 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/jobs/GroupAvatarDownloadJob.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/jobs/GroupAvatarDownloadJob.kt @@ -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 }