|
|
|
@ -28,6 +28,8 @@
|
|
|
|
|
#import "TSSubmitMessageRequest.h"
|
|
|
|
|
#import "TSRecipientPrekeyRequest.h"
|
|
|
|
|
|
|
|
|
|
#import "TSErrorMessage.h"
|
|
|
|
|
|
|
|
|
|
#import "TSContactThread.h"
|
|
|
|
|
#import "TSGroupThread.h"
|
|
|
|
|
#import "TSRecipient.h"
|
|
|
|
@ -88,11 +90,17 @@ dispatch_queue_t sendingQueue() {
|
|
|
|
|
} failure:^(NSURLSessionDataTask *task, NSError *error) {
|
|
|
|
|
NSHTTPURLResponse *response = (NSHTTPURLResponse *)task.response;
|
|
|
|
|
long statuscode = response.statusCode;
|
|
|
|
|
|
|
|
|
|
switch (statuscode) {
|
|
|
|
|
case 404:
|
|
|
|
|
// Recipient not found
|
|
|
|
|
case 404:{
|
|
|
|
|
DDLogError(@"Recipient not found");
|
|
|
|
|
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
|
|
|
|
[recipient removeWithTransaction:transaction];
|
|
|
|
|
[message setMessageState:TSOutgoingMessageStateUnsent];
|
|
|
|
|
[[TSErrorMessage userNotRegisteredErrorMessageInThread:thread] saveWithTransaction:transaction];
|
|
|
|
|
}];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 409:
|
|
|
|
|
// Mismatched devices
|
|
|
|
|
DDLogError(@"Missing some devices");
|
|
|
|
@ -102,14 +110,16 @@ dispatch_queue_t sendingQueue() {
|
|
|
|
|
DDLogWarn(@"Stale devices");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
|
|
|
|
[message setMessageState:TSOutgoingMessageStateUnsent];
|
|
|
|
|
[message saveWithTransaction:transaction];
|
|
|
|
|
}];
|
|
|
|
|
[self sendMessage:message toRecipient:recipient inThread:thread withAttemps:remainingAttempts];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
}];
|
|
|
|
|
} else{
|
|
|
|
|
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
|
|
|
|
[message setMessageState:TSOutgoingMessageStateUnsent];
|
|
|
|
|
[message saveWithTransaction:transaction];
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|