Fix issue with GV1 avatars using attachmentsV3.

master
Greyson Parrelli 2020-07-21 15:02:57 -04:00
parent 870cee5707
commit 813c820227
3 changed files with 17 additions and 11 deletions

View File

@ -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;
}

View File

@ -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();
})

View File

@ -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);