mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 02:10:44 +01:00
Add call link support to storage service.
This commit is contained in:
committed by
Cody Henthorne
parent
1f2b5e90a3
commit
e247d311d8
@@ -155,9 +155,10 @@ public class ApplicationMigrations {
|
||||
static final int EXPIRE_TIMER_CAPABILITY_2 = 111;
|
||||
// static final int BACKFILL_DIGESTS = 112;
|
||||
static final int BACKFILL_DIGESTS_V2 = 113;
|
||||
static final int CALL_LINK_STORAGE_SYNC = 114;
|
||||
}
|
||||
|
||||
public static final int CURRENT_VERSION = 113;
|
||||
public static final int CURRENT_VERSION = 114;
|
||||
|
||||
/**
|
||||
* This *must* be called after the {@link JobManager} has been instantiated, but *before* the call
|
||||
@@ -708,6 +709,10 @@ public class ApplicationMigrations {
|
||||
jobs.put(Version.BACKFILL_DIGESTS_V2, new BackfillDigestsMigrationJob());
|
||||
}
|
||||
|
||||
if (lastSeenVersion < Version.CALL_LINK_STORAGE_SYNC) {
|
||||
jobs.put(Version.CALL_LINK_STORAGE_SYNC, new SyncCallLinksMigrationJob());
|
||||
}
|
||||
|
||||
return jobs;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2024 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.thoughtcrime.securesms.migrations
|
||||
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
|
||||
/**
|
||||
* Marks all call links as needing to be synced by storage service.
|
||||
*/
|
||||
internal class SyncCallLinksMigrationJob @JvmOverloads constructor(parameters: Parameters = Parameters.Builder().build()) : MigrationJob(parameters) {
|
||||
|
||||
companion object {
|
||||
const val KEY = "SyncCallLinksMigrationJob"
|
||||
|
||||
private val TAG = Log.tag(SyncCallLinksMigrationJob::class)
|
||||
}
|
||||
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
override fun isUiBlocking(): Boolean = false
|
||||
|
||||
override fun performMigration() {
|
||||
if (SignalStore.account.aci == null) {
|
||||
Log.w(TAG, "Self not available yet.")
|
||||
return
|
||||
}
|
||||
|
||||
val callLinkRecipients = SignalDatabase.callLinks.getAll().map { it.recipientId }.filter {
|
||||
try {
|
||||
Recipient.resolved(it)
|
||||
true
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Unable to resolve recipient: $it")
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
SignalDatabase.recipients.markNeedsSync(callLinkRecipients)
|
||||
StorageSyncHelper.scheduleSyncForDataChange()
|
||||
}
|
||||
|
||||
override fun shouldRetry(e: Exception): Boolean = false
|
||||
|
||||
class Factory : Job.Factory<SyncCallLinksMigrationJob> {
|
||||
override fun create(parameters: Parameters, serializedData: ByteArray?): SyncCallLinksMigrationJob {
|
||||
return SyncCallLinksMigrationJob(parameters)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user