|
|
|
@ -1111,9 +1111,37 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
|
|
|
|
// Convert the message to a Loki message and send it using the Loki messaging API
|
|
|
|
|
NSDictionary *signalMessage = deviceMessages.firstObject;
|
|
|
|
|
BOOL isPoWRequired = YES; // TODO: Base on message type
|
|
|
|
|
[LokiAPI sendSignalMessage:signalMessage to:recipient.recipientId requiringPoW:isPoWRequired completionHandler:^(id response, NSError *error) {
|
|
|
|
|
// TODO: Use the response
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[[LokiAPI sendSignalMessage:signalMessage to:recipient.recipientId requiringPoW:isPoWRequired]
|
|
|
|
|
.thenOn([OWSDispatch sendingQueue], ^(id result) {
|
|
|
|
|
[self messageSendDidSucceed:messageSend
|
|
|
|
|
deviceMessages:deviceMessages
|
|
|
|
|
wasSentByUD:false
|
|
|
|
|
wasSentByWebsocket:false];
|
|
|
|
|
})
|
|
|
|
|
.catchOn([OWSDispatch sendingQueue], ^(NSError *error) {
|
|
|
|
|
NSUInteger statusCode = 0;
|
|
|
|
|
NSData *_Nullable responseData = nil;
|
|
|
|
|
if ([error.domain isEqualToString:TSNetworkManagerErrorDomain]) {
|
|
|
|
|
statusCode = error.code;
|
|
|
|
|
|
|
|
|
|
NSError *_Nullable underlyingError = error.userInfo[NSUnderlyingErrorKey];
|
|
|
|
|
if (underlyingError) {
|
|
|
|
|
responseData
|
|
|
|
|
= underlyingError.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey];
|
|
|
|
|
} else {
|
|
|
|
|
OWSFailDebug(@"Missing underlying error: %@", error);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
OWSFailDebug(@"Unexpected error: %@", error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[self messageSendDidFail:messageSend
|
|
|
|
|
deviceMessages:deviceMessages
|
|
|
|
|
statusCode:statusCode
|
|
|
|
|
error:error
|
|
|
|
|
responseData:responseData];
|
|
|
|
|
}) retainUntilComplete];
|
|
|
|
|
|
|
|
|
|
// Loki: Original code
|
|
|
|
|
/*
|
|
|
|
|