Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for resending badly-encrypted stories.
- Loading branch information
1 parent
7873ec2
commit c6be427
Showing
11 changed files
with
288 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...crime/securesms/jobmanager/migrations/SenderKeyDistributionSendJobRecipientMigration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.