Search in sources :

Example 1 with ResumableUploadSpecJob

use of org.thoughtcrime.securesms.jobs.ResumableUploadSpecJob in project Signal-Android by WhisperSystems.

the class MessageSender method preUploadPushAttachment.

/**
 * @return A result if the attachment was enqueued, or null if it failed to enqueue or shouldn't
 *         be enqueued (like in the case of a local self-send).
 */
@Nullable
public static PreUploadResult preUploadPushAttachment(@NonNull Context context, @NonNull Attachment attachment, @Nullable Recipient recipient) {
    if (isLocalSelfSend(context, recipient, false)) {
        return null;
    }
    Log.i(TAG, "Pre-uploading attachment for " + (recipient != null ? recipient.getId() : "null"));
    try {
        AttachmentDatabase attachmentDatabase = SignalDatabase.attachments();
        DatabaseAttachment databaseAttachment = attachmentDatabase.insertAttachmentForPreUpload(attachment);
        Job compressionJob = AttachmentCompressionJob.fromAttachment(databaseAttachment, false, -1);
        Job resumableUploadSpecJob = new ResumableUploadSpecJob();
        Job uploadJob = new AttachmentUploadJob(databaseAttachment.getAttachmentId());
        ApplicationDependencies.getJobManager().startChain(compressionJob).then(resumableUploadSpecJob).then(uploadJob).enqueue();
        return new PreUploadResult(databaseAttachment.getAttachmentId(), Arrays.asList(compressionJob.getId(), resumableUploadSpecJob.getId(), uploadJob.getId()));
    } catch (MmsException e) {
        Log.w(TAG, "preUploadPushAttachment() - Failed to upload!", e);
        return null;
    }
}
Also used : MmsException(org.thoughtcrime.securesms.mms.MmsException) DatabaseAttachment(org.thoughtcrime.securesms.attachments.DatabaseAttachment) ResumableUploadSpecJob(org.thoughtcrime.securesms.jobs.ResumableUploadSpecJob) AttachmentMarkUploadedJob(org.thoughtcrime.securesms.jobs.AttachmentMarkUploadedJob) ReactionSendJob(org.thoughtcrime.securesms.jobs.ReactionSendJob) PushMediaSendJob(org.thoughtcrime.securesms.jobs.PushMediaSendJob) Job(org.thoughtcrime.securesms.jobmanager.Job) ResumableUploadSpecJob(org.thoughtcrime.securesms.jobs.ResumableUploadSpecJob) PushGroupSendJob(org.thoughtcrime.securesms.jobs.PushGroupSendJob) AttachmentCompressionJob(org.thoughtcrime.securesms.jobs.AttachmentCompressionJob) ProfileKeySendJob(org.thoughtcrime.securesms.jobs.ProfileKeySendJob) RemoteDeleteSendJob(org.thoughtcrime.securesms.jobs.RemoteDeleteSendJob) MmsSendJob(org.thoughtcrime.securesms.jobs.MmsSendJob) AttachmentUploadJob(org.thoughtcrime.securesms.jobs.AttachmentUploadJob) PushTextSendJob(org.thoughtcrime.securesms.jobs.PushTextSendJob) AttachmentCopyJob(org.thoughtcrime.securesms.jobs.AttachmentCopyJob) SmsSendJob(org.thoughtcrime.securesms.jobs.SmsSendJob) AttachmentDatabase(org.thoughtcrime.securesms.database.AttachmentDatabase) AttachmentUploadJob(org.thoughtcrime.securesms.jobs.AttachmentUploadJob) Nullable(androidx.annotation.Nullable)

Aggregations

Nullable (androidx.annotation.Nullable)1 DatabaseAttachment (org.thoughtcrime.securesms.attachments.DatabaseAttachment)1 AttachmentDatabase (org.thoughtcrime.securesms.database.AttachmentDatabase)1 Job (org.thoughtcrime.securesms.jobmanager.Job)1 AttachmentCompressionJob (org.thoughtcrime.securesms.jobs.AttachmentCompressionJob)1 AttachmentCopyJob (org.thoughtcrime.securesms.jobs.AttachmentCopyJob)1 AttachmentMarkUploadedJob (org.thoughtcrime.securesms.jobs.AttachmentMarkUploadedJob)1 AttachmentUploadJob (org.thoughtcrime.securesms.jobs.AttachmentUploadJob)1 MmsSendJob (org.thoughtcrime.securesms.jobs.MmsSendJob)1 ProfileKeySendJob (org.thoughtcrime.securesms.jobs.ProfileKeySendJob)1 PushGroupSendJob (org.thoughtcrime.securesms.jobs.PushGroupSendJob)1 PushMediaSendJob (org.thoughtcrime.securesms.jobs.PushMediaSendJob)1 PushTextSendJob (org.thoughtcrime.securesms.jobs.PushTextSendJob)1 ReactionSendJob (org.thoughtcrime.securesms.jobs.ReactionSendJob)1 RemoteDeleteSendJob (org.thoughtcrime.securesms.jobs.RemoteDeleteSendJob)1 ResumableUploadSpecJob (org.thoughtcrime.securesms.jobs.ResumableUploadSpecJob)1 SmsSendJob (org.thoughtcrime.securesms.jobs.SmsSendJob)1 MmsException (org.thoughtcrime.securesms.mms.MmsException)1