mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-22 10:46:50 +00:00
Do not double-insert change number events.
This commit is contained in:
@@ -75,7 +75,6 @@ import org.thoughtcrime.securesms.groups.GroupId.V1
|
||||
import org.thoughtcrime.securesms.groups.GroupId.V2
|
||||
import org.thoughtcrime.securesms.groups.v2.ProfileKeySet
|
||||
import org.thoughtcrime.securesms.groups.v2.processing.GroupsV2StateProcessor
|
||||
import org.thoughtcrime.securesms.jobs.RecipientChangedNumberJob
|
||||
import org.thoughtcrime.securesms.jobs.RequestGroupV2InfoJob
|
||||
import org.thoughtcrime.securesms.jobs.RetrieveProfileJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
@@ -490,10 +489,6 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
||||
StorageSyncHelper.scheduleSyncForDataChange()
|
||||
RecipientId.clearCache()
|
||||
}
|
||||
|
||||
if (result.changedNumberId != null) {
|
||||
ApplicationDependencies.getJobManager().add(RecipientChangedNumberJob(result.changedNumberId!!))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +157,6 @@ public final class JobManagerFactories {
|
||||
put(PushProcessMessageJob.KEY, new PushProcessMessageJob.Factory());
|
||||
put(PushTextSendJob.KEY, new PushTextSendJob.Factory());
|
||||
put(ReactionSendJob.KEY, new ReactionSendJob.Factory());
|
||||
put(RecipientChangedNumberJob.KEY, new RecipientChangedNumberJob.Factory());
|
||||
put(RefreshAttributesJob.KEY, new RefreshAttributesJob.Factory());
|
||||
put(RefreshOwnProfileJob.KEY, new RefreshOwnProfileJob.Factory());
|
||||
put(RemoteConfigRefreshJob.KEY, new RemoteConfigRefreshJob.Factory());
|
||||
@@ -254,6 +253,7 @@ public final class JobManagerFactories {
|
||||
put("RotateSignedPreKeyJob", new PreKeysSyncJob.Factory());
|
||||
put("CreateSignedPreKeyJob", new PreKeysSyncJob.Factory());
|
||||
put("RefreshPreKeysJob", new PreKeysSyncJob.Factory());
|
||||
put("RecipientChangedNumberJob", new FailingJob.Factory());
|
||||
}};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
package org.thoughtcrime.securesms.jobs
|
||||
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.jobmanager.Data
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
|
||||
/**
|
||||
* Insert change number update items in all threads (1:1 and group) with [recipientId].
|
||||
*/
|
||||
class RecipientChangedNumberJob(parameters: Parameters, private val recipientId: RecipientId) : BaseJob(parameters) {
|
||||
|
||||
constructor(recipientId: RecipientId) : this(
|
||||
Parameters.Builder().setQueue("RecipientChangedNumberJob_${recipientId.toQueueKey()}").build(),
|
||||
recipientId
|
||||
)
|
||||
|
||||
override fun serialize(): Data {
|
||||
return Data.Builder()
|
||||
.putString(KEY_RECIPIENT_ID, recipientId.serialize())
|
||||
.build()
|
||||
}
|
||||
|
||||
override fun getFactoryKey(): String {
|
||||
return KEY
|
||||
}
|
||||
|
||||
override fun onRun() {
|
||||
val recipient: Recipient = Recipient.resolved(recipientId)
|
||||
|
||||
if (!recipient.isBlocked && !recipient.isGroup && !recipient.isSelf) {
|
||||
Log.i(TAG, "Writing a number change event.")
|
||||
SignalDatabase.sms.insertNumberChangeMessages(recipient.id)
|
||||
} else {
|
||||
Log.i(TAG, "Number changed but not relevant. blocked: ${recipient.isBlocked} isGroup: ${recipient.isGroup} isSelf: ${recipient.isSelf}")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onShouldRetry(e: Exception): Boolean = false
|
||||
|
||||
override fun onFailure() = Unit
|
||||
|
||||
class Factory : Job.Factory<RecipientChangedNumberJob> {
|
||||
override fun create(parameters: Parameters, data: Data): RecipientChangedNumberJob {
|
||||
return RecipientChangedNumberJob(parameters, RecipientId.from(data.getString(KEY_RECIPIENT_ID)))
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val KEY = "RecipientChangedNumberJob"
|
||||
|
||||
private val TAG = Log.tag(RecipientChangedNumberJob::class.java)
|
||||
private const val KEY_RECIPIENT_ID = "recipient_id"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user