mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-26 22:20:20 +00:00
Fix sepa badge redemption job.
This commit is contained in:
@@ -43,7 +43,7 @@ public class JobManager implements ConstraintObserver.Notifier {
|
||||
|
||||
private static final String TAG = Log.tag(JobManager.class);
|
||||
|
||||
public static final int CURRENT_VERSION = 10;
|
||||
public static final int CURRENT_VERSION = 11;
|
||||
|
||||
private final Application application;
|
||||
private final Configuration configuration;
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
package org.thoughtcrime.securesms.jobmanager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Create a subclass of this to perform a migration on persisted {@link Job}s. A migration targets
|
||||
* a specific end version, and the assumption is that it can migrate jobs to that end version from
|
||||
* the previous version. The class will be provided a bundle of job data for each persisted job and
|
||||
* give back an updated version (if applicable).
|
||||
*/
|
||||
public abstract class JobMigration {
|
||||
|
||||
private final int endVersion;
|
||||
|
||||
protected JobMigration(int endVersion) {
|
||||
this.endVersion = endVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a bundle of job data, return a bundle of job data that should be used in place of it.
|
||||
* You may obviously return the same object if you don't wish to change it.
|
||||
*/
|
||||
protected abstract @NonNull JobData migrate(@NonNull JobData jobData);
|
||||
|
||||
int getEndVersion() {
|
||||
return endVersion;
|
||||
}
|
||||
|
||||
public static class JobData {
|
||||
|
||||
private final String factoryKey;
|
||||
private final String queueKey;
|
||||
private final byte[] data;
|
||||
|
||||
public JobData(@NonNull String factoryKey, @Nullable String queueKey, @Nullable byte[] data) {
|
||||
this.factoryKey = factoryKey;
|
||||
this.queueKey = queueKey;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public @NonNull JobData withFactoryKey(@NonNull String newFactoryKey) {
|
||||
return new JobData(newFactoryKey, queueKey, data);
|
||||
}
|
||||
|
||||
public @NonNull JobData withQueueKey(@Nullable String newQueueKey) {
|
||||
return new JobData(factoryKey, newQueueKey, data);
|
||||
}
|
||||
|
||||
public @NonNull JobData withData(@Nullable byte[] newData) {
|
||||
return new JobData(factoryKey, queueKey, newData);
|
||||
}
|
||||
|
||||
public @NonNull String getFactoryKey() {
|
||||
return factoryKey;
|
||||
}
|
||||
|
||||
public @Nullable String getQueueKey() {
|
||||
return queueKey;
|
||||
}
|
||||
|
||||
public @NonNull byte[] getData() {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.thoughtcrime.securesms.jobmanager
|
||||
|
||||
/**
|
||||
* Create a subclass of this to perform a migration on persisted [Job]s. A migration targets
|
||||
* a specific end version, and the assumption is that it can migrate jobs to that end version from
|
||||
* the previous version. The class will be provided a bundle of job data for each persisted job and
|
||||
* give back an updated version (if applicable).
|
||||
*/
|
||||
abstract class JobMigration protected constructor(val endVersion: Int) {
|
||||
|
||||
/**
|
||||
* Given a bundle of job data, return a bundle of job data that should be used in place of it.
|
||||
* You may obviously return the same object if you don't wish to change it.
|
||||
*/
|
||||
abstract fun migrate(jobData: JobData): JobData
|
||||
|
||||
data class JobData(
|
||||
val factoryKey: String,
|
||||
val queueKey: String?,
|
||||
val maxAttempts: Int,
|
||||
val lifespan: Long,
|
||||
val data: ByteArray?
|
||||
) {
|
||||
fun withFactoryKey(newFactoryKey: String): JobData {
|
||||
return copy(factoryKey = newFactoryKey)
|
||||
}
|
||||
|
||||
fun withQueueKey(newQueueKey: String?): JobData {
|
||||
return copy(queueKey = newQueueKey)
|
||||
}
|
||||
|
||||
fun withData(newData: ByteArray?): JobData {
|
||||
return copy(data = newData)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val FAILING_JOB_DATA = JobData("FailingJob", null, -1, -1, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class JobMigrator {
|
||||
|
||||
while (iter.hasNext()) {
|
||||
JobSpec jobSpec = iter.next();
|
||||
JobData originalJobData = new JobData(jobSpec.getFactoryKey(), jobSpec.getQueueKey(), jobSpec.getSerializedData());
|
||||
JobData originalJobData = new JobData(jobSpec.getFactoryKey(), jobSpec.getQueueKey(), jobSpec.getMaxAttempts(), jobSpec.getLifespan(), jobSpec.getSerializedData());
|
||||
JobData updatedJobData = migration.migrate(originalJobData);
|
||||
JobSpec updatedJobSpec = new JobSpec(jobSpec.getId(),
|
||||
updatedJobData.getFactoryKey(),
|
||||
@@ -68,8 +68,8 @@ public class JobMigrator {
|
||||
jobSpec.getLastRunAttemptTime(),
|
||||
jobSpec.getNextBackoffInterval(),
|
||||
jobSpec.getRunAttempt(),
|
||||
jobSpec.getMaxAttempts(),
|
||||
jobSpec.getLifespan(),
|
||||
updatedJobData.getMaxAttempts(),
|
||||
updatedJobData.getLifespan(),
|
||||
updatedJobData.getData(),
|
||||
jobSpec.getSerializedInputData(),
|
||||
jobSpec.isRunning(),
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.thoughtcrime.securesms.jobmanager.migrations
|
||||
|
||||
import org.thoughtcrime.securesms.jobmanager.JobMigration
|
||||
|
||||
/**
|
||||
* Migrate DonationReceiptRedemptionJob to use more lax lifespan and retries to accommodate SEPA.
|
||||
*/
|
||||
class DonationReceiptRedemptionJobMigration : JobMigration(11) {
|
||||
override fun migrate(jobData: JobData): JobData {
|
||||
return if ("DonationReceiptRedemptionJob" == jobData.factoryKey) {
|
||||
jobData.copy(
|
||||
maxAttempts = 1500,
|
||||
lifespan = -1
|
||||
)
|
||||
} else {
|
||||
jobData
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public class PushDecryptMessageJobEnvelopeMigration extends JobMigration {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull JobData migrate(@NonNull JobData jobData) {
|
||||
public @NonNull JobData migrate(@NonNull JobData jobData) {
|
||||
return jobData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class PushProcessMessageQueueJobMigration extends JobMigration {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull JobData migrate(@NonNull JobData jobData) {
|
||||
public @NonNull JobData migrate(@NonNull JobData jobData) {
|
||||
if ("PushProcessJob".equals(jobData.getFactoryKey())) {
|
||||
Log.i(TAG, "Found a PushProcessMessageJob to migrate.");
|
||||
try {
|
||||
|
||||
@@ -21,7 +21,7 @@ public class RecipientIdFollowUpJobMigration extends JobMigration {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull JobData migrate(@NonNull JobData jobData) {
|
||||
public @NonNull JobData migrate(@NonNull JobData jobData) {
|
||||
switch(jobData.getFactoryKey()) {
|
||||
case "RequestGroupInfoJob": return migrateRequestGroupInfoJob(jobData);
|
||||
case "SendDeliveryReceiptJob": return migrateSendDeliveryReceiptJob(jobData);
|
||||
@@ -54,6 +54,6 @@ public class RecipientIdFollowUpJobMigration extends JobMigration {
|
||||
}
|
||||
|
||||
private static JobData failingJobData() {
|
||||
return new JobData("FailingJob", null, null);
|
||||
return JobData.FAILING_JOB_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class RecipientIdJobMigration extends JobMigration {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull JobData migrate(@NonNull JobData jobData) {
|
||||
public @NonNull JobData migrate(@NonNull JobData jobData) {
|
||||
switch(jobData.getFactoryKey()) {
|
||||
case "MultiDeviceContactUpdateJob": return migrateMultiDeviceContactUpdateJob(jobData);
|
||||
case "MultiDeviceRevealUpdateJob": return migrateMultiDeviceViewOnceOpenJob(jobData);
|
||||
|
||||
@@ -15,7 +15,7 @@ public class RetrieveProfileJobMigration extends JobMigration {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull JobData migrate(@NonNull JobData jobData) {
|
||||
public @NonNull JobData migrate(@NonNull JobData jobData) {
|
||||
Log.i(TAG, "Running.");
|
||||
|
||||
if ("RetrieveProfileJob".equals(jobData.getFactoryKey())) {
|
||||
|
||||
@@ -19,7 +19,7 @@ public class SendReadReceiptsJobMigration extends JobMigration {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull JobData migrate(@NonNull JobData jobData) {
|
||||
public @NonNull JobData migrate(@NonNull JobData jobData) {
|
||||
if ("SendReadReceiptJob".equals(jobData.getFactoryKey())) {
|
||||
return migrateSendReadReceiptJob(messageTable, jobData);
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class SendReadReceiptsJobMigration extends JobMigration {
|
||||
}
|
||||
|
||||
if (threadIds.size() != 1) {
|
||||
return new JobData("FailingJob", null, null);
|
||||
return JobData.FAILING_JOB_DATA;
|
||||
} else {
|
||||
return jobData.withData(data.buildUpon().putLong("thread", threadIds.first()).serialize());
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class SenderKeyDistributionSendJobRecipientMigration extends JobMigration
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull JobData migrate(@NonNull JobData jobData) {
|
||||
public @NonNull JobData migrate(@NonNull JobData jobData) {
|
||||
if ("SenderKeyDistributionSendJob".equals(jobData.getFactoryKey())) {
|
||||
return migrateJob(jobData, groupDatabase);
|
||||
} else {
|
||||
|
||||
@@ -28,17 +28,15 @@ import org.whispersystems.signalservice.internal.ServiceResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okio.ByteString;
|
||||
|
||||
/**
|
||||
* Job to redeem a verified donation receipt. It is up to the Job prior in the chain to specify a valid
|
||||
* presentation object via setOutputData. This is expected to be the byte[] blob of a ReceiptCredentialPresentation object.
|
||||
*/
|
||||
public class DonationReceiptRedemptionJob extends BaseJob {
|
||||
private static final String TAG = Log.tag(DonationReceiptRedemptionJob.class);
|
||||
private static final long NO_ID = -1L;
|
||||
private static final String TAG = Log.tag(DonationReceiptRedemptionJob.class);
|
||||
private static final long NO_ID = -1L;
|
||||
private static final int MAX_RETRIES = 1500;
|
||||
|
||||
public static final String SUBSCRIPTION_QUEUE = "ReceiptRedemption";
|
||||
public static final String ONE_TIME_QUEUE = "BoostReceiptRedemption";
|
||||
@@ -71,8 +69,8 @@ public class DonationReceiptRedemptionJob extends BaseJob {
|
||||
.Builder()
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
.setQueue(SUBSCRIPTION_QUEUE + (isLongRunningDonationPaymentType ? LONG_RUNNING_QUEUE_SUFFIX : ""))
|
||||
.setMaxAttempts(Parameters.UNLIMITED)
|
||||
.setLifespan(TimeUnit.DAYS.toMillis(1))
|
||||
.setMaxAttempts(MAX_RETRIES)
|
||||
.setLifespan(Parameters.IMMORTAL)
|
||||
.build());
|
||||
}
|
||||
|
||||
@@ -86,8 +84,8 @@ public class DonationReceiptRedemptionJob extends BaseJob {
|
||||
.Builder()
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
.setQueue(ONE_TIME_QUEUE + (isLongRunningDonationPaymentType ? LONG_RUNNING_QUEUE_SUFFIX : ""))
|
||||
.setMaxAttempts(Parameters.UNLIMITED)
|
||||
.setLifespan(TimeUnit.DAYS.toMillis(1))
|
||||
.setMaxAttempts(MAX_RETRIES)
|
||||
.setLifespan(Parameters.IMMORTAL)
|
||||
.build());
|
||||
}
|
||||
|
||||
@@ -112,8 +110,8 @@ public class DonationReceiptRedemptionJob extends BaseJob {
|
||||
.Builder()
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
.setQueue("GiftReceiptRedemption-" + messageId)
|
||||
.setMaxAttempts(Parameters.UNLIMITED)
|
||||
.setLifespan(TimeUnit.DAYS.toMillis(1))
|
||||
.setMaxAttempts(MAX_RETRIES)
|
||||
.setLifespan(Parameters.IMMORTAL)
|
||||
.build());
|
||||
|
||||
RefreshOwnProfileJob refreshOwnProfileJob = new RefreshOwnProfileJob();
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.thoughtcrime.securesms.jobmanager.impl.NotInCallConstraint;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NotInCallConstraintObserver;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.SqlCipherMigrationConstraint;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.SqlCipherMigrationConstraintObserver;
|
||||
import org.thoughtcrime.securesms.jobmanager.migrations.DonationReceiptRedemptionJobMigration;
|
||||
import org.thoughtcrime.securesms.jobmanager.migrations.PushDecryptMessageJobEnvelopeMigration;
|
||||
import org.thoughtcrime.securesms.jobmanager.migrations.PushProcessMessageJobMigration;
|
||||
import org.thoughtcrime.securesms.jobmanager.migrations.PushProcessMessageQueueJobMigration;
|
||||
@@ -343,6 +344,7 @@ public final class JobManagerFactories {
|
||||
new RetrieveProfileJobMigration(),
|
||||
new PushDecryptMessageJobEnvelopeMigration(),
|
||||
new SenderKeyDistributionSendJobRecipientMigration(),
|
||||
new PushProcessMessageJobMigration());
|
||||
new PushProcessMessageJobMigration(),
|
||||
new DonationReceiptRedemptionJobMigration());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,8 +112,8 @@ public final class FeatureFlags {
|
||||
public static final String USERNAMES = "android.usernames";
|
||||
public static final String INSTANT_VIDEO_PLAYBACK = "android.instantVideoPlayback";
|
||||
public static final String CRASH_PROMPT_CONFIG = "android.crashPromptConfig";
|
||||
private static final String SEPA_DEBIT_DONATIONS = "android.sepa.debit.donations.4";
|
||||
private static final String IDEAL_DONATIONS = "android.ideal.donations.4";
|
||||
private static final String SEPA_DEBIT_DONATIONS = "android.sepa.debit.donations.5";
|
||||
private static final String IDEAL_DONATIONS = "android.ideal.donations.5";
|
||||
public static final String IDEAL_ENABLED_REGIONS = "global.donations.idealEnabledRegions";
|
||||
public static final String SEPA_ENABLED_REGIONS = "global.donations.sepaEnabledRegions";
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public class JobMigratorTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull JobData migrate(@NonNull JobData jobData) {
|
||||
public @NonNull JobData migrate(@NonNull JobData jobData) {
|
||||
return jobData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,10 +30,10 @@ public class RecipientIdFollowUpJobMigrationTest {
|
||||
|
||||
@Test
|
||||
public void migrate_sendDeliveryReceiptJob_good() throws Exception {
|
||||
JobData testData = new JobData("SendDeliveryReceiptJob", null, new JsonJobData.Builder().putString("recipient", "1")
|
||||
.putLong("message_id", 1)
|
||||
.putLong("timestamp", 2)
|
||||
.serialize());
|
||||
JobData testData = new JobData("SendDeliveryReceiptJob", null, -1, -1, new JsonJobData.Builder().putString("recipient", "1")
|
||||
.putLong("message_id", 1)
|
||||
.putLong("timestamp", 2)
|
||||
.serialize());
|
||||
RecipientIdFollowUpJobMigration subject = new RecipientIdFollowUpJobMigration();
|
||||
JobData converted = subject.migrate(testData);
|
||||
|
||||
@@ -50,8 +50,8 @@ public class RecipientIdFollowUpJobMigrationTest {
|
||||
|
||||
@Test
|
||||
public void migrate_sendDeliveryReceiptJob_bad() throws Exception {
|
||||
JobData testData = new JobData("SendDeliveryReceiptJob", null, new JsonJobData.Builder().putString("recipient", "1")
|
||||
.serialize());
|
||||
JobData testData = new JobData("SendDeliveryReceiptJob", null, -1, -1, new JsonJobData.Builder().putString("recipient", "1")
|
||||
.serialize());
|
||||
RecipientIdFollowUpJobMigration subject = new RecipientIdFollowUpJobMigration();
|
||||
JobData converted = subject.migrate(testData);
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public class RecipientIdJobMigrationTest {
|
||||
|
||||
@Test
|
||||
public void migrate_multiDeviceContactUpdateJob() throws Exception {
|
||||
JobData testData = new JobData("MultiDeviceContactUpdateJob", "MultiDeviceContactUpdateJob", new JsonJobData.Builder().putBoolean("force_sync", false).putString("address", "+16101234567").serialize());
|
||||
JobData testData = new JobData("MultiDeviceContactUpdateJob", "MultiDeviceContactUpdateJob", -1, -1, new JsonJobData.Builder().putBoolean("force_sync", false).putString("address", "+16101234567").serialize());
|
||||
mockRecipientResolve("+16101234567", 1);
|
||||
|
||||
RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
|
||||
@@ -68,7 +68,7 @@ public class RecipientIdJobMigrationTest {
|
||||
@Test
|
||||
public void migrate_multiDeviceViewOnceOpenJob() throws Exception {
|
||||
OldSerializableSyncMessageId oldId = new OldSerializableSyncMessageId("+16101234567", 1);
|
||||
JobData testData = new JobData("MultiDeviceRevealUpdateJob", null, new JsonJobData.Builder().putString("message_id", JsonUtils.toJson(oldId)).serialize());
|
||||
JobData testData = new JobData("MultiDeviceRevealUpdateJob", null, -1, -1, new JsonJobData.Builder().putString("message_id", JsonUtils.toJson(oldId)).serialize());
|
||||
mockRecipientResolve("+16101234567", 1);
|
||||
|
||||
RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
|
||||
@@ -84,10 +84,10 @@ public class RecipientIdJobMigrationTest {
|
||||
|
||||
@Test
|
||||
public void migrate_sendDeliveryReceiptJob() throws Exception {
|
||||
JobData testData = new JobData("SendDeliveryReceiptJob", null, new JsonJobData.Builder().putString("address", "+16101234567")
|
||||
.putLong("message_id", 1)
|
||||
.putLong("timestamp", 2)
|
||||
.serialize());
|
||||
JobData testData = new JobData("SendDeliveryReceiptJob", null, -1, -1, new JsonJobData.Builder().putString("address", "+16101234567")
|
||||
.putLong("message_id", 1)
|
||||
.putLong("timestamp", 2)
|
||||
.serialize());
|
||||
mockRecipientResolve("+16101234567", 1);
|
||||
|
||||
RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
|
||||
@@ -105,11 +105,11 @@ public class RecipientIdJobMigrationTest {
|
||||
|
||||
@Test
|
||||
public void migrate_multiDeviceVerifiedUpdateJob() throws Exception {
|
||||
JobData testData = new JobData("MultiDeviceVerifiedUpdateJob", "__MULTI_DEVICE_VERIFIED_UPDATE__", new JsonJobData.Builder().putString("destination", "+16101234567")
|
||||
.putString("identity_key", "abcd")
|
||||
.putInt("verified_status", 1)
|
||||
.putLong("timestamp", 123)
|
||||
.serialize());
|
||||
JobData testData = new JobData("MultiDeviceVerifiedUpdateJob", "__MULTI_DEVICE_VERIFIED_UPDATE__", -1, -1, new JsonJobData.Builder().putString("destination", "+16101234567")
|
||||
.putString("identity_key", "abcd")
|
||||
.putInt("verified_status", 1)
|
||||
.putLong("timestamp", 123)
|
||||
.serialize());
|
||||
mockRecipientResolve("+16101234567", 1);
|
||||
|
||||
RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
|
||||
@@ -128,9 +128,9 @@ public class RecipientIdJobMigrationTest {
|
||||
|
||||
@Test
|
||||
public void migrate_pushGroupSendJob_null() throws Exception {
|
||||
JobData testData = new JobData("PushGroupSendJob", "someGroupId", new JsonJobData.Builder().putString("filter_address", null)
|
||||
.putLong("message_id", 123)
|
||||
.serialize());
|
||||
JobData testData = new JobData("PushGroupSendJob", "someGroupId", -1, -1, new JsonJobData.Builder().putString("filter_address", null)
|
||||
.putLong("message_id", 123)
|
||||
.serialize());
|
||||
mockRecipientResolve("someGroupId", 5);
|
||||
|
||||
RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
|
||||
@@ -147,9 +147,9 @@ public class RecipientIdJobMigrationTest {
|
||||
|
||||
@Test
|
||||
public void migrate_pushGroupSendJob_nonNull() throws Exception {
|
||||
JobData testData = new JobData("PushGroupSendJob", "someGroupId", new JsonJobData.Builder().putString("filter_address", "+16101234567")
|
||||
.putLong("message_id", 123)
|
||||
.serialize());
|
||||
JobData testData = new JobData("PushGroupSendJob", "someGroupId", -1, -1, new JsonJobData.Builder().putString("filter_address", "+16101234567")
|
||||
.putLong("message_id", 123)
|
||||
.serialize());
|
||||
mockRecipientResolve("+16101234567", 1);
|
||||
mockRecipientResolve("someGroupId", 5);
|
||||
|
||||
@@ -167,7 +167,7 @@ public class RecipientIdJobMigrationTest {
|
||||
|
||||
@Test
|
||||
public void migrate_directoryRefreshJob_null() throws Exception {
|
||||
JobData testData = new JobData("DirectoryRefreshJob", "DirectoryRefreshJob", new JsonJobData.Builder().putString("address", null).putBoolean("notify_of_new_users", true).serialize());
|
||||
JobData testData = new JobData("DirectoryRefreshJob", "DirectoryRefreshJob", -1, -1, new JsonJobData.Builder().putString("address", null).putBoolean("notify_of_new_users", true).serialize());
|
||||
|
||||
RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
|
||||
JobData converted = subject.migrate(testData);
|
||||
@@ -184,7 +184,7 @@ public class RecipientIdJobMigrationTest {
|
||||
|
||||
@Test
|
||||
public void migrate_directoryRefreshJob_nonNull() throws Exception {
|
||||
JobData testData = new JobData("DirectoryRefreshJob", "DirectoryRefreshJob", new JsonJobData.Builder().putString("address", "+16101234567").putBoolean("notify_of_new_users", true).serialize());
|
||||
JobData testData = new JobData("DirectoryRefreshJob", "DirectoryRefreshJob", -1, -1, new JsonJobData.Builder().putString("address", "+16101234567").putBoolean("notify_of_new_users", true).serialize());
|
||||
mockRecipientResolve("+16101234567", 1);
|
||||
|
||||
RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
|
||||
@@ -202,7 +202,7 @@ public class RecipientIdJobMigrationTest {
|
||||
|
||||
@Test
|
||||
public void migrate_retrieveProfileAvatarJob() throws Exception {
|
||||
JobData testData = new JobData("RetrieveProfileAvatarJob", "RetrieveProfileAvatarJob+16101234567", new JsonJobData.Builder().putString("address", "+16101234567").putString("profile_avatar", "abc").serialize());
|
||||
JobData testData = new JobData("RetrieveProfileAvatarJob", "RetrieveProfileAvatarJob+16101234567", -1, -1, new JsonJobData.Builder().putString("address", "+16101234567").putString("profile_avatar", "abc").serialize());
|
||||
mockRecipientResolve("+16101234567", 1);
|
||||
|
||||
RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
|
||||
@@ -219,7 +219,7 @@ public class RecipientIdJobMigrationTest {
|
||||
|
||||
@Test
|
||||
public void migrate_multiDeviceReadUpdateJob_empty() throws Exception {
|
||||
JobData testData = new JobData("MultiDeviceReadUpdateJob", null, new JsonJobData.Builder().putStringArray("message_ids", new String[0]).serialize());
|
||||
JobData testData = new JobData("MultiDeviceReadUpdateJob", null, -1, -1, new JsonJobData.Builder().putStringArray("message_ids", new String[0]).serialize());
|
||||
|
||||
RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
|
||||
JobData converted = subject.migrate(testData);
|
||||
@@ -237,7 +237,7 @@ public class RecipientIdJobMigrationTest {
|
||||
OldSerializableSyncMessageId id1 = new OldSerializableSyncMessageId("+16101234567", 1);
|
||||
OldSerializableSyncMessageId id2 = new OldSerializableSyncMessageId("+16101112222", 2);
|
||||
|
||||
JobData testData = new JobData("MultiDeviceReadUpdateJob", null, new JsonJobData.Builder().putStringArray("message_ids", new String[]{ JsonUtils.toJson(id1), JsonUtils.toJson(id2) }).serialize());
|
||||
JobData testData = new JobData("MultiDeviceReadUpdateJob", null, -1, -1, new JsonJobData.Builder().putStringArray("message_ids", new String[]{ JsonUtils.toJson(id1), JsonUtils.toJson(id2) }).serialize());
|
||||
mockRecipientResolve("+16101234567", 1);
|
||||
mockRecipientResolve("+16101112222", 2);
|
||||
|
||||
@@ -259,7 +259,7 @@ public class RecipientIdJobMigrationTest {
|
||||
|
||||
@Test
|
||||
public void migrate_pushMediaSendJob() throws Exception {
|
||||
JobData testData = new JobData("PushMediaSendJob", "+16101234567", new JsonJobData.Builder().putLong("message_id", 1).serialize());
|
||||
JobData testData = new JobData("PushMediaSendJob", "+16101234567", -1, -1, new JsonJobData.Builder().putLong("message_id", 1).serialize());
|
||||
mockRecipientResolve("+16101234567", 1);
|
||||
|
||||
RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
|
||||
@@ -275,7 +275,7 @@ public class RecipientIdJobMigrationTest {
|
||||
|
||||
@Test
|
||||
public void migrate_smsSendJob_nonNull() throws Exception {
|
||||
JobData testData = new JobData("SmsSendJob", "+16101234567", new JsonJobData.Builder().putLong("message_id", 1).putInt("run_attempt", 0).serialize());
|
||||
JobData testData = new JobData("SmsSendJob", "+16101234567", -1, -1, new JsonJobData.Builder().putLong("message_id", 1).putInt("run_attempt", 0).serialize());
|
||||
mockRecipientResolve("+16101234567", 1);
|
||||
|
||||
RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
|
||||
@@ -292,7 +292,7 @@ public class RecipientIdJobMigrationTest {
|
||||
|
||||
@Test
|
||||
public void migrate_smsSendJob_null() throws Exception {
|
||||
JobData testData = new JobData("SmsSendJob", null, new JsonJobData.Builder().putLong("message_id", 1).putInt("run_attempt", 0).serialize());
|
||||
JobData testData = new JobData("SmsSendJob", null, -1, -1, new JsonJobData.Builder().putLong("message_id", 1).putInt("run_attempt", 0).serialize());
|
||||
mockRecipientResolve("+16101234567", 1);
|
||||
|
||||
RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
|
||||
|
||||
@@ -26,6 +26,8 @@ public class SendReadReceiptsJobMigrationTest {
|
||||
SendReadReceiptJob job = new SendReadReceiptJob(1, RecipientId.from(2), new ArrayList<>(), new ArrayList<>());
|
||||
JobMigration.JobData jobData = new JobMigration.JobData(job.getFactoryKey(),
|
||||
"asdf",
|
||||
-1,
|
||||
-1,
|
||||
new JsonJobData.Builder()
|
||||
.putString("recipient", RecipientId.from(2).serialize())
|
||||
.putLongArray("message_ids", new long[]{1, 2, 3, 4, 5})
|
||||
@@ -49,6 +51,8 @@ public class SendReadReceiptsJobMigrationTest {
|
||||
SendReadReceiptJob job = new SendReadReceiptJob(1, RecipientId.from(2), new ArrayList<>(), new ArrayList<>());
|
||||
JobMigration.JobData jobData = new JobMigration.JobData(job.getFactoryKey(),
|
||||
"asdf",
|
||||
-1,
|
||||
-1,
|
||||
new JsonJobData.Builder()
|
||||
.putString("recipient", RecipientId.from(2).serialize())
|
||||
.putLongArray("message_ids", new long[]{})
|
||||
@@ -66,7 +70,7 @@ public class SendReadReceiptsJobMigrationTest {
|
||||
public void givenSendReadReceiptJobDataWithThreadId_whenIMigrate_thenIDoNotReplace() {
|
||||
// GIVEN
|
||||
SendReadReceiptJob job = new SendReadReceiptJob(1, RecipientId.from(2), new ArrayList<>(), new ArrayList<>());
|
||||
JobMigration.JobData jobData = new JobMigration.JobData(job.getFactoryKey(), "asdf", job.serialize());
|
||||
JobMigration.JobData jobData = new JobMigration.JobData(job.getFactoryKey(), "asdf", -1, -1, job.serialize());
|
||||
|
||||
// WHEN
|
||||
JobMigration.JobData result = testSubject.migrate(jobData);
|
||||
@@ -78,7 +82,7 @@ public class SendReadReceiptsJobMigrationTest {
|
||||
@Test
|
||||
public void givenSomeOtherJobDataWithThreadId_whenIMigrate_thenIDoNotReplace() {
|
||||
// GIVEN
|
||||
JobMigration.JobData jobData = new JobMigration.JobData("SomeOtherJob", "asdf", new JsonJobData.Builder().putLong("thread", 1).serialize());
|
||||
JobMigration.JobData jobData = new JobMigration.JobData("SomeOtherJob", "asdf", -1, -1, new JsonJobData.Builder().putLong("thread", 1).serialize());
|
||||
|
||||
// WHEN
|
||||
JobMigration.JobData result = testSubject.migrate(jobData);
|
||||
@@ -90,7 +94,7 @@ public class SendReadReceiptsJobMigrationTest {
|
||||
@Test
|
||||
public void givenSomeOtherJobDataWithoutThreadId_whenIMigrate_thenIDoNotReplace() {
|
||||
// GIVEN
|
||||
JobMigration.JobData jobData = new JobMigration.JobData("SomeOtherJob", "asdf", new JsonJobData.Builder().serialize());
|
||||
JobMigration.JobData jobData = new JobMigration.JobData("SomeOtherJob", "asdf", -1, -1, new JsonJobData.Builder().serialize());
|
||||
|
||||
// WHEN
|
||||
JobMigration.JobData result = testSubject.migrate(jobData);
|
||||
|
||||
@@ -30,6 +30,8 @@ public class SenderKeyDistributionSendJobRecipientMigrationTest {
|
||||
// GIVEN
|
||||
JobMigration.JobData jobData = new JobMigration.JobData(SenderKeyDistributionSendJob.KEY,
|
||||
"asdf",
|
||||
-1,
|
||||
-1,
|
||||
new JsonJobData.Builder()
|
||||
.putString("recipient_id", RecipientId.from(1).serialize())
|
||||
.putBlobAsString("group_id", GROUP_ID.getDecodedId())
|
||||
@@ -53,6 +55,8 @@ public class SenderKeyDistributionSendJobRecipientMigrationTest {
|
||||
// GIVEN
|
||||
JobMigration.JobData jobData = new JobMigration.JobData(SenderKeyDistributionSendJob.KEY,
|
||||
"asdf",
|
||||
-1,
|
||||
-1,
|
||||
new JsonJobData.Builder()
|
||||
.putString("recipient_id", RecipientId.from(1).serialize())
|
||||
.putBlobAsString("group_id", GROUP_ID.getDecodedId())
|
||||
@@ -70,6 +74,8 @@ public class SenderKeyDistributionSendJobRecipientMigrationTest {
|
||||
// GIVEN
|
||||
JobMigration.JobData jobData = new JobMigration.JobData(SenderKeyDistributionSendJob.KEY,
|
||||
"asdf",
|
||||
-1,
|
||||
-1,
|
||||
new JsonJobData.Builder()
|
||||
.putString("recipient_id", RecipientId.from(1).serialize())
|
||||
.serialize());
|
||||
|
||||
Reference in New Issue
Block a user