|
|
|
@ -69,7 +69,7 @@ public final class MessageSendJob : NSObject, Job, NSCoding { // NSObject/NSCodi
|
|
|
|
|
if storage.getAttachmentUploadJob(for: attachment.uniqueId!) != nil {
|
|
|
|
|
// Wait for it to finish
|
|
|
|
|
} else {
|
|
|
|
|
let job = AttachmentUploadJob()
|
|
|
|
|
let job = AttachmentUploadJob(attachmentID: attachment.uniqueId!, threadID: message.threadID!)
|
|
|
|
|
storage.withAsync({ transaction in
|
|
|
|
|
JobQueue.shared.add(job, using: transaction)
|
|
|
|
|
}, completion: { })
|
|
|
|
@ -83,9 +83,13 @@ public final class MessageSendJob : NSObject, Job, NSCoding { // NSObject/NSCodi
|
|
|
|
|
self.handleSuccess()
|
|
|
|
|
}.catch(on: Threading.workQueue) { error in
|
|
|
|
|
SNLog("Couldn't send message due to error: \(error).")
|
|
|
|
|
if let error = error as? MessageSender.Error, !error.isRetryable {
|
|
|
|
|
self.handlePermanentFailure(error: error)
|
|
|
|
|
} else {
|
|
|
|
|
self.handleFailure(error: error)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, completion: { })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -93,6 +97,10 @@ public final class MessageSendJob : NSObject, Job, NSCoding { // NSObject/NSCodi
|
|
|
|
|
delegate?.handleJobSucceeded(self)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private func handlePermanentFailure(error: Error) {
|
|
|
|
|
delegate?.handleJobFailedPermanently(self, with: error)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private func handleFailure(error: Error) {
|
|
|
|
|
delegate?.handleJobFailed(self, with: error)
|
|
|
|
|
}
|
|
|
|
|