From 2af0cc7bb21488f2b3e53d8a6f16324cfa53e100 Mon Sep 17 00:00:00 2001 From: 0x330a <92654767+0x330a@users.noreply.github.com> Date: Fri, 17 Mar 2023 11:53:10 +1100 Subject: [PATCH] fix: open group sync persistence --- .../org/thoughtcrime/securesms/groups/OpenGroupManager.kt | 2 +- .../securesms/util/ConfigurationMessageUtilities.kt | 2 ++ .../libsession/messaging/jobs/GroupAvatarDownloadJob.kt | 7 ++++++- 3 files changed, 9 insertions(+), 2 deletions(-) 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 06d9f05e25..1f27a36c2f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/groups/OpenGroupManager.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/groups/OpenGroupManager.kt @@ -104,7 +104,7 @@ object OpenGroupManager { val storage = MessagingModuleConfiguration.shared.storage val configFactory = MessagingModuleConfiguration.shared.configFactory val threadDB = DatabaseComponent.get(context).threadDatabase() - val openGroupID = "$server.$room" + val openGroupID = "${server.removeSuffix("/")}.$room" val threadID = GroupManager.getOpenGroupThreadID(openGroupID, context) val recipient = threadDB.getRecipientForThreadId(threadID) ?: return threadDB.setThreadArchived(threadID) diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/ConfigurationMessageUtilities.kt b/app/src/main/java/org/thoughtcrime/securesms/util/ConfigurationMessageUtilities.kt index e2121f4d3a..ca74da5548 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/ConfigurationMessageUtilities.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/util/ConfigurationMessageUtilities.kt @@ -74,10 +74,12 @@ object ConfigurationMessageUtilities { if (ConfigBase.isNewConfigEnabled) { // schedule job if none exist // don't schedule job if we already have one + Log.d("Loki-DBG", "Forcing config sync") val ourDestination = Destination.Contact(userPublicKey) val currentStorageJob = storage.getConfigSyncJob(ourDestination) if (currentStorageJob != null) { (currentStorageJob as ConfigurationSyncJob).shouldRunAgain.set(true) + Log.d("Loki-DBG", "Not scheduling another one") return Promise.ofFail(NullPointerException("A job is already pending or in progress, don't schedule another job")) } val newConfigSync = ConfigurationSyncJob(ourDestination) 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 9571f44e76..476798ff5e 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 @@ -18,7 +18,12 @@ class GroupAvatarDownloadJob(val server: String, val room: String, val imageId: return } val storage = MessagingModuleConfiguration.shared.storage - val storedImageId = storage.getOpenGroup(room, server)?.imageId + val openGroup = storage.getOpenGroup(room, server) + if (openGroup == null) { + delegate?.handleJobFailedPermanently(this, dispatcherName, Exception("GroupAvatarDownloadJob openGroup is null")) + return + } + val storedImageId = openGroup.imageId if (storedImageId == null || storedImageId != imageId) { delegate?.handleJobFailedPermanently(this, dispatcherName, Exception("GroupAvatarDownloadJob imageId does not match the OpenGroup"))