Skip to content

Commit

Permalink
Fix issue with GV1 avatars using attachmentsV3.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Jul 21, 2020
1 parent 870cee5 commit 813c820
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ private AttachmentUploadJob(@NonNull Job.Parameters parameters, @NonNull Attachm

@Override
public void onRun() throws Exception {
final ResumableUploadSpec resumableUploadSpec;
if (FeatureFlags.attachmentsV3()) {
Data inputData = requireInputData();
if (!inputData.hasString(ResumableUploadSpecJob.KEY_RESUME_SPEC)) {
throw new ResumeLocationInvalidException("V3 Attachment upload requires a ResumableUploadSpec");
}
Data inputData = getInputData();

ResumableUploadSpec resumableUploadSpec;

if (inputData != null && inputData.hasString(ResumableUploadSpecJob.KEY_RESUME_SPEC)) {
Log.d(TAG, "Using attachments V3");
resumableUploadSpec = ResumableUploadSpec.deserialize(inputData.getString(ResumableUploadSpecJob.KEY_RESUME_SPEC));
} else {
Log.d(TAG, "Using attachments V2");
resumableUploadSpec = null;
}

Expand Down
14 changes: 10 additions & 4 deletions app/src/main/java/org/thoughtcrime/securesms/jobs/PushSendJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,16 @@ protected static Set<String> enqueueCompressingAndUploadAttachmentsChains(@NonNu
return new HashSet<>(Stream.of(attachments).map(a -> {
AttachmentUploadJob attachmentUploadJob = new AttachmentUploadJob(((DatabaseAttachment) a).getAttachmentId());

jobManager.startChain(AttachmentCompressionJob.fromAttachment((DatabaseAttachment) a, false, -1))
.then(new ResumableUploadSpecJob())
.then(attachmentUploadJob)
.enqueue();
if (message.isGroup()) {
jobManager.startChain(AttachmentCompressionJob.fromAttachment((DatabaseAttachment) a, false, -1))
.then(attachmentUploadJob)
.enqueue();
} else {
jobManager.startChain(AttachmentCompressionJob.fromAttachment((DatabaseAttachment) a, false, -1))
.then(new ResumableUploadSpecJob())
.then(attachmentUploadJob)
.enqueue();
}

return attachmentUploadJob.getId();
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public SignalServiceAttachmentPointer uploadAttachment(SignalServiceAttachmentSt
attachment.getCancelationSignal(),
attachment.getResumableUploadSpec().orNull());

if (attachmentsV3.get()) {
if (attachment.getResumableUploadSpec().isPresent()) {
return uploadAttachmentV3(attachment, attachmentKey, attachmentData);
} else {
return uploadAttachmentV2(attachment, attachmentKey, attachmentData);
Expand Down

0 comments on commit 813c820

Please sign in to comment.