fix: open group sync persistence

This commit is contained in:
0x330a 2023-03-17 11:53:10 +11:00
parent 61e8935725
commit 2af0cc7bb2
3 changed files with 9 additions and 2 deletions

View File

@ -104,7 +104,7 @@ object OpenGroupManager {
val storage = MessagingModuleConfiguration.shared.storage val storage = MessagingModuleConfiguration.shared.storage
val configFactory = MessagingModuleConfiguration.shared.configFactory val configFactory = MessagingModuleConfiguration.shared.configFactory
val threadDB = DatabaseComponent.get(context).threadDatabase() val threadDB = DatabaseComponent.get(context).threadDatabase()
val openGroupID = "$server.$room" val openGroupID = "${server.removeSuffix("/")}.$room"
val threadID = GroupManager.getOpenGroupThreadID(openGroupID, context) val threadID = GroupManager.getOpenGroupThreadID(openGroupID, context)
val recipient = threadDB.getRecipientForThreadId(threadID) ?: return val recipient = threadDB.getRecipientForThreadId(threadID) ?: return
threadDB.setThreadArchived(threadID) threadDB.setThreadArchived(threadID)

View File

@ -74,10 +74,12 @@ object ConfigurationMessageUtilities {
if (ConfigBase.isNewConfigEnabled) { if (ConfigBase.isNewConfigEnabled) {
// schedule job if none exist // schedule job if none exist
// don't schedule job if we already have one // don't schedule job if we already have one
Log.d("Loki-DBG", "Forcing config sync")
val ourDestination = Destination.Contact(userPublicKey) val ourDestination = Destination.Contact(userPublicKey)
val currentStorageJob = storage.getConfigSyncJob(ourDestination) val currentStorageJob = storage.getConfigSyncJob(ourDestination)
if (currentStorageJob != null) { if (currentStorageJob != null) {
(currentStorageJob as ConfigurationSyncJob).shouldRunAgain.set(true) (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")) return Promise.ofFail(NullPointerException("A job is already pending or in progress, don't schedule another job"))
} }
val newConfigSync = ConfigurationSyncJob(ourDestination) val newConfigSync = ConfigurationSyncJob(ourDestination)

View File

@ -18,7 +18,12 @@ class GroupAvatarDownloadJob(val server: String, val room: String, val imageId:
return return
} }
val storage = MessagingModuleConfiguration.shared.storage 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) { if (storedImageId == null || storedImageId != imageId) {
delegate?.handleJobFailedPermanently(this, dispatcherName, Exception("GroupAvatarDownloadJob imageId does not match the OpenGroup")) delegate?.handleJobFailedPermanently(this, dispatcherName, Exception("GroupAvatarDownloadJob imageId does not match the OpenGroup"))