mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 02:10:44 +01:00
Add support for resending badly-encrypted stories.
This commit is contained in:
committed by
Alex Hart
parent
7873ec2b67
commit
c6be427883
@@ -44,7 +44,7 @@ public class JobManager implements ConstraintObserver.Notifier {
|
||||
|
||||
private static final String TAG = Log.tag(JobManager.class);
|
||||
|
||||
public static final int CURRENT_VERSION = 8;
|
||||
public static final int CURRENT_VERSION = 9;
|
||||
|
||||
private final Application application;
|
||||
private final Configuration configuration;
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package org.thoughtcrime.securesms.jobmanager.migrations;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobMigration;
|
||||
import org.thoughtcrime.securesms.jobs.FailingJob;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* We removed the messageId property from the job data and replaced it with a serialized envelope,
|
||||
* so we need to take jobs that referenced an ID and replace it with the envelope instead.
|
||||
*/
|
||||
public class SenderKeyDistributionSendJobRecipientMigration extends JobMigration {
|
||||
|
||||
private static final String TAG = Log.tag(SenderKeyDistributionSendJobRecipientMigration.class);
|
||||
|
||||
private final GroupDatabase groupDatabase;
|
||||
|
||||
public SenderKeyDistributionSendJobRecipientMigration() {
|
||||
this(SignalDatabase.groups());
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
SenderKeyDistributionSendJobRecipientMigration(GroupDatabase groupDatabase) {
|
||||
super(9);
|
||||
this.groupDatabase = groupDatabase;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull JobData migrate(@NonNull JobData jobData) {
|
||||
if ("SenderKeyDistributionSendJob".equals(jobData.getFactoryKey())) {
|
||||
return migrateJob(jobData, groupDatabase);
|
||||
} else {
|
||||
return jobData;
|
||||
}
|
||||
}
|
||||
|
||||
private static @NonNull JobData migrateJob(@NonNull JobData jobData, @NonNull GroupDatabase groupDatabase) {
|
||||
Data data = jobData.getData();
|
||||
|
||||
if (data.hasString("group_id")) {
|
||||
GroupId groupId = GroupId.pushOrThrow(data.getStringAsBlob("group_id"));
|
||||
Optional<GroupRecord> group = groupDatabase.getGroup(groupId);
|
||||
|
||||
if (group.isPresent()) {
|
||||
return jobData.withData(data.buildUpon()
|
||||
.putString("thread_recipient_id", group.get().getRecipientId().serialize())
|
||||
.build());
|
||||
|
||||
} else {
|
||||
return jobData.withFactoryKey(FailingJob.KEY);
|
||||
}
|
||||
} else if (!data.hasString("thread_recipient_id")) {
|
||||
return jobData.withFactoryKey(FailingJob.KEY);
|
||||
} else {
|
||||
return jobData;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user