From 813c82022795384e89baafd23a30389faf5cf2af Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Tue, 21 Jul 2020 15:02:57 -0400 Subject: [PATCH] Fix issue with GV1 avatars using attachmentsV3. --- .../securesms/jobs/AttachmentUploadJob.java | 12 ++++++------ .../thoughtcrime/securesms/jobs/PushSendJob.java | 14 ++++++++++---- .../api/SignalServiceMessageSender.java | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/AttachmentUploadJob.java b/app/src/main/java/org/thoughtcrime/securesms/jobs/AttachmentUploadJob.java index 5b3bf0b34..ade4ad6ba 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/AttachmentUploadJob.java +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/AttachmentUploadJob.java @@ -94,15 +94,15 @@ public final class AttachmentUploadJob extends BaseJob { @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; } diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushSendJob.java b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushSendJob.java index 745e5e94c..2ccd7812e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushSendJob.java +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushSendJob.java @@ -168,10 +168,16 @@ public abstract class PushSendJob extends SendJob { 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(); }) diff --git a/libsignal/service/src/main/java/org/whispersystems/signalservice/api/SignalServiceMessageSender.java b/libsignal/service/src/main/java/org/whispersystems/signalservice/api/SignalServiceMessageSender.java index 90ef035e7..9b7d16fbb 100644 --- a/libsignal/service/src/main/java/org/whispersystems/signalservice/api/SignalServiceMessageSender.java +++ b/libsignal/service/src/main/java/org/whispersystems/signalservice/api/SignalServiceMessageSender.java @@ -381,7 +381,7 @@ public class SignalServiceMessageSender { attachment.getCancelationSignal(), attachment.getResumableUploadSpec().orNull()); - if (attachmentsV3.get()) { + if (attachment.getResumableUploadSpec().isPresent()) { return uploadAttachmentV3(attachment, attachmentKey, attachmentData); } else { return uploadAttachmentV2(attachment, attachmentKey, attachmentData);