mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-09-28 07:51:42 +01:00
Rotate storage service for mentions.
This commit is contained in:
@@ -900,6 +900,21 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
}
|
||||
}
|
||||
|
||||
fun markAllGV2NeedsSync() {
|
||||
writableDatabase.withinTransaction { db ->
|
||||
db
|
||||
.select(ID)
|
||||
.from(TABLE_NAME)
|
||||
.where("$TYPE = ? AND $STORAGE_SERVICE_ID NOT NULL", RecipientType.GV2.id)
|
||||
.run()
|
||||
.use { cursor ->
|
||||
while (cursor.moveToNext()) {
|
||||
rotateStorageId(RecipientId.from(cursor.requireLong(ID)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun applyStorageIdUpdates(storageIds: Map<RecipientId, StorageId>) {
|
||||
val db = writableDatabase
|
||||
db.beginTransaction()
|
||||
|
||||
@@ -83,6 +83,7 @@ import org.thoughtcrime.securesms.migrations.KeyTransparencyFailureMigrationJob;
|
||||
import org.thoughtcrime.securesms.migrations.KeyTransparencyUsernameMigrationJob;
|
||||
import org.thoughtcrime.securesms.migrations.LegacyMigrationJob;
|
||||
import org.thoughtcrime.securesms.migrations.LocalArchiveReconciliationMigrationJob;
|
||||
import org.thoughtcrime.securesms.migrations.MentionsStorageServiceMigrationJob;
|
||||
import org.thoughtcrime.securesms.migrations.MigrationCompleteJob;
|
||||
import org.thoughtcrime.securesms.migrations.OptimizeMessageSearchIndexMigrationJob;
|
||||
import org.thoughtcrime.securesms.migrations.PassingMigrationJob;
|
||||
@@ -360,6 +361,7 @@ public final class JobManagerFactories {
|
||||
put(KeyTransparencyUsernameMigrationJob.KEY, new KeyTransparencyUsernameMigrationJob.Factory());
|
||||
put(LegacyMigrationJob.KEY, new LegacyMigrationJob.Factory());
|
||||
put(LocalArchiveReconciliationMigrationJob.KEY, new LocalArchiveReconciliationMigrationJob.Factory());
|
||||
put(MentionsStorageServiceMigrationJob.KEY, new MentionsStorageServiceMigrationJob.Factory());
|
||||
put(MigrationCompleteJob.KEY, new MigrationCompleteJob.Factory());
|
||||
put(OptimizeMessageSearchIndexMigrationJob.KEY, new OptimizeMessageSearchIndexMigrationJob.Factory());
|
||||
put(PinOptOutMigration.KEY, new PinOptOutMigration.Factory());
|
||||
|
||||
@@ -217,9 +217,10 @@ public class ApplicationMigrations {
|
||||
static final int CLEAR_ZK_CREDENTIALS = 172;
|
||||
static final int SVR2_ENCLAVE_UPDATE_7 = 173;
|
||||
static final int DISABLE_UNREAD_REMINDER = 174;
|
||||
static final int MENTIONS_STORAGE_SERVICE = 175;
|
||||
}
|
||||
|
||||
public static final int CURRENT_VERSION = 174;
|
||||
public static final int CURRENT_VERSION = 175;
|
||||
|
||||
/**
|
||||
* This *must* be called after the {@link JobManager} has been instantiated, but *before* the call
|
||||
@@ -1006,6 +1007,10 @@ public class ApplicationMigrations {
|
||||
jobs.put(Version.DISABLE_UNREAD_REMINDER, new DisableUnreadReminderMigrationJob());
|
||||
}
|
||||
|
||||
if (lastSeenVersion < Version.MENTIONS_STORAGE_SERVICE) {
|
||||
jobs.put(Version.MENTIONS_STORAGE_SERVICE, new MentionsStorageServiceMigrationJob());
|
||||
}
|
||||
|
||||
return jobs;
|
||||
}
|
||||
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package org.thoughtcrime.securesms.migrations
|
||||
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.core.util.logging.Log.tag
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
|
||||
/**
|
||||
* Rotates the storage service id for every GV2 group to support writing the new mentions setting
|
||||
*/
|
||||
internal class MentionsStorageServiceMigrationJob private constructor(parameters: Parameters) : MigrationJob(parameters) {
|
||||
|
||||
companion object {
|
||||
|
||||
const val KEY = "MentionsStorageServiceMigrationJob"
|
||||
|
||||
private val TAG: String = tag(MentionsStorageServiceMigrationJob::class.java)
|
||||
}
|
||||
|
||||
internal constructor() : this(Parameters.Builder().build())
|
||||
|
||||
override fun isUiBlocking(): Boolean = false
|
||||
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
override fun performMigration() {
|
||||
if (!SignalStore.account.isRegistered || SignalStore.account.aci == null) {
|
||||
Log.i(TAG, "Unregistered, skipping.")
|
||||
return
|
||||
}
|
||||
|
||||
SignalDatabase.recipients.markAllGV2NeedsSync()
|
||||
StorageSyncHelper.scheduleSyncForDataChange()
|
||||
}
|
||||
|
||||
override fun shouldRetry(e: Exception): Boolean = false
|
||||
|
||||
class Factory : Job.Factory<MentionsStorageServiceMigrationJob> {
|
||||
override fun create(parameters: Parameters, serializedData: ByteArray?): MentionsStorageServiceMigrationJob {
|
||||
return MentionsStorageServiceMigrationJob(parameters)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user