mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 00:59:49 +01:00
Fix incorrect left group in local state bug.
This commit is contained in:
@@ -168,9 +168,10 @@ public class ApplicationMigrations {
|
||||
static final int GPB_TOKEN_MIGRATION = 124;
|
||||
static final int GROUP_ADD_MIGRATION = 125;
|
||||
static final int SSRE2_CAPABILITY = 126;
|
||||
static final int FIX_INACTIVE_GROUPS = 127;
|
||||
}
|
||||
|
||||
public static final int CURRENT_VERSION = 126;
|
||||
public static final int CURRENT_VERSION = 127;
|
||||
|
||||
/**
|
||||
* This *must* be called after the {@link JobManager} has been instantiated, but *before* the call
|
||||
@@ -773,6 +774,10 @@ public class ApplicationMigrations {
|
||||
jobs.put(Version.SSRE2_CAPABILITY, new AttributesMigrationJob());
|
||||
}
|
||||
|
||||
if (lastSeenVersion < Version.FIX_INACTIVE_GROUPS) {
|
||||
jobs.put(Version.FIX_INACTIVE_GROUPS, new InactiveGroupCheckMigrationJob());
|
||||
}
|
||||
|
||||
return jobs;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package org.thoughtcrime.securesms.migrations
|
||||
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedGroup
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobs.RequestGroupV2InfoJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.whispersystems.signalservice.api.push.ServiceId
|
||||
import org.whispersystems.signalservice.api.push.ServiceIds
|
||||
|
||||
/**
|
||||
* Migration to fix groups that we locally marked as inactive because of the server
|
||||
* but may not actually be left.
|
||||
*/
|
||||
internal class InactiveGroupCheckMigrationJob(
|
||||
parameters: Parameters = Parameters.Builder().build()
|
||||
) : MigrationJob(parameters) {
|
||||
|
||||
companion object {
|
||||
val TAG = Log.tag(InactiveGroupCheckMigrationJob::class.java)
|
||||
const val KEY = "InactiveGroupCheckMigrationJob"
|
||||
}
|
||||
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
override fun isUiBlocking(): Boolean = false
|
||||
|
||||
override fun performMigration() {
|
||||
if (SignalStore.account.aci == null) {
|
||||
Log.w(TAG, "ACI missing, abort")
|
||||
return
|
||||
}
|
||||
|
||||
val serviceIds = SignalStore.account.getServiceIds()
|
||||
|
||||
SignalDatabase
|
||||
.groups
|
||||
.getInactiveGroups()
|
||||
.use { reader ->
|
||||
reader
|
||||
.asSequence()
|
||||
.filter { it.isV2Group }
|
||||
.filter { it.requireV2GroupProperties().decryptedGroup.isMember(serviceIds) }
|
||||
.forEach {
|
||||
AppDependencies.jobManager.add(RequestGroupV2InfoJob(it.id.requireV2()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun DecryptedGroup.isMember(serviceIds: ServiceIds): Boolean {
|
||||
return this
|
||||
.members
|
||||
.asSequence()
|
||||
.mapNotNull { ServiceId.ACI.Companion.parseOrNull(it.aciBytes) }
|
||||
.any { serviceIds.matches(it) }
|
||||
}
|
||||
|
||||
override fun shouldRetry(e: Exception): Boolean = false
|
||||
|
||||
class Factory : Job.Factory<InactiveGroupCheckMigrationJob> {
|
||||
override fun create(parameters: Parameters, serializedData: ByteArray?): InactiveGroupCheckMigrationJob {
|
||||
return InactiveGroupCheckMigrationJob(parameters)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user