@ -23,6 +23,7 @@ public enum MessageSendJob: JobExecutor {
let detailsData : Data = job . details ,
let detailsData : Data = job . details ,
let details : Details = try ? JSONDecoder ( ) . decode ( Details . self , from : detailsData )
let details : Details = try ? JSONDecoder ( ) . decode ( Details . self , from : detailsData )
else {
else {
SNLog ( " [MessageSendJob] Failing due to missing details " )
failure ( job , JobRunnerError . missingRequiredDetails , true )
failure ( job , JobRunnerError . missingRequiredDetails , true )
return
return
}
}
@ -45,6 +46,7 @@ public enum MessageSendJob: JobExecutor {
let jobId : Int64 = job . id ,
let jobId : Int64 = job . id ,
let interactionId : Int64 = job . interactionId
let interactionId : Int64 = job . interactionId
else {
else {
SNLog ( " [MessageSendJob] Failing due to missing details " )
failure ( job , JobRunnerError . missingRequiredDetails , true )
failure ( job , JobRunnerError . missingRequiredDetails , true )
return
return
}
}
@ -52,6 +54,7 @@ public enum MessageSendJob: JobExecutor {
// I f t h e o r i g i n a l i n t e r a c t i o n n o l o n g e r e x i s t s t h e n d o n ' t b o t h e r s e n d i n g t h e m e s s a g e ( i e . t h e
// I f t h e o r i g i n a l i n t e r a c t i o n n o l o n g e r e x i s t s t h e n d o n ' t b o t h e r s e n d i n g t h e m e s s a g e ( i e . t h e
// m e s s a g e w a s d e l e t e d b e f o r e i t e v e n g o t s e n t )
// m e s s a g e w a s d e l e t e d b e f o r e i t e v e n g o t s e n t )
guard Storage . shared . read ( { db in try Interaction . exists ( db , id : interactionId ) } ) = = true else {
guard Storage . shared . read ( { db in try Interaction . exists ( db , id : interactionId ) } ) = = true else {
SNLog ( " [MessageSendJob] Failing due to missing interaction " )
failure ( job , StorageError . objectNotFound , true )
failure ( job , StorageError . objectNotFound , true )
return
return
}
}
@ -150,12 +153,14 @@ public enum MessageSendJob: JobExecutor {
// N o t e : I f w e h a v e g o t t e n t o t h i s p o i n t t h e n a n y d e p e n d a n t a t t a c h m e n t u p l o a d
// N o t e : I f w e h a v e g o t t e n t o t h i s p o i n t t h e n a n y d e p e n d a n t a t t a c h m e n t u p l o a d
// j o b s w i l l h a v e p e r m a n e n t l y f a i l e d s o t h i s m e s s a g e s e n d s h o u l d a l s o d o s o
// j o b s w i l l h a v e p e r m a n e n t l y f a i l e d s o t h i s m e s s a g e s e n d s h o u l d a l s o d o s o
guard attachmentState ? . shouldFail = = false else {
guard attachmentState ? . shouldFail = = false else {
SNLog ( " [MessageSendJob] Failing due to failed attachment upload " )
failure ( job , AttachmentError . notUploaded , true )
failure ( job , AttachmentError . notUploaded , true )
return
return
}
}
// D e f e r t h e j o b i f w e f o u n d i n c o m p l e t e u p l o a d s
// D e f e r t h e j o b i f w e f o u n d i n c o m p l e t e u p l o a d s
guard attachmentState ? . shouldDefer = = false else {
guard attachmentState ? . shouldDefer = = false else {
SNLog ( " [MessageSendJob] Deferring pending attachment uploads " )
deferred ( job )
deferred ( job )
return
return
}
}
@ -190,7 +195,7 @@ public enum MessageSendJob: JobExecutor {
switch result {
switch result {
case . finished : success ( job , false )
case . finished : success ( job , false )
case . failure ( let error ) :
case . failure ( let error ) :
SNLog ( " Couldn't send message due to error: \( error ) . " )
SNLog ( " [MessageSendJob] Couldn't send message due to error: \( error ) . " )
switch error {
switch error {
case let senderError as MessageSenderError where ! senderError . isRetryable :
case let senderError as MessageSenderError where ! senderError . isRetryable :
@ -200,11 +205,11 @@ public enum MessageSendJob: JobExecutor {
failure ( job , error , true )
failure ( job , error , true )
case SnodeAPIError . clockOutOfSync :
case SnodeAPIError . clockOutOfSync :
SNLog ( " \( originalSentTimestamp != nil ? " Permanently Failing " : " Failing " ) to send \( type ( of : details . message ) ) due to clock out of sync issue. " )
SNLog ( " [MessageSendJob] \( originalSentTimestamp != nil ? " Permanently Failing " : " Failing " ) to send \( type ( of : details . message ) ) due to clock out of sync issue. " )
failure ( job , error , ( originalSentTimestamp != nil ) )
failure ( job , error , ( originalSentTimestamp != nil ) )
default :
default :
SNLog ( " Failed to send \( type ( of : details . message ) ) . " )
SNLog ( " [MessageSendJob] Failed to send \( type ( of : details . message ) ) . " )
if details . message is VisibleMessage {
if details . message is VisibleMessage {
guard
guard