|
|
@ -220,35 +220,27 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
animated:YES
|
|
|
|
animated:YES
|
|
|
|
completion:^(void) {
|
|
|
|
completion:^(void) {
|
|
|
|
__block TSOutgoingMessage *outgoingMessage = nil;
|
|
|
|
__block TSOutgoingMessage *outgoingMessage = nil;
|
|
|
|
if (self.attachment.isOversizeText
|
|
|
|
if (self.attachment.isUrl && self.attachment.captionText.length > 0) {
|
|
|
|
&& self.attachment.dataLength <= kOversizeTextMessageSizeThreshold) {
|
|
|
|
// Urls are added to the caption text, so discard the attachment
|
|
|
|
// Try to unpack oversize text messages and send them as regular
|
|
|
|
// and send the caption as a regular text message.
|
|
|
|
// text messages if possible.
|
|
|
|
NSString *messageText = self.attachment.captionText;
|
|
|
|
NSData *_Nullable data = self.attachment.data;
|
|
|
|
outgoingMessage = [ThreadUtil sendMessageWithText:messageText
|
|
|
|
if (!data) {
|
|
|
|
inThread:self.thread
|
|
|
|
DDLogError(@"%@ couldn't load data for oversize text attachment", self.logTag);
|
|
|
|
messageSender:self.messageSender
|
|
|
|
} else {
|
|
|
|
success:^{
|
|
|
|
NSString *messageText =
|
|
|
|
sendCompletion(nil, outgoingMessage);
|
|
|
|
[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
|
|
|
}
|
|
|
|
outgoingMessage = [ThreadUtil sendMessageWithText:messageText
|
|
|
|
failure:^(NSError *_Nonnull error) {
|
|
|
|
inThread:self.thread
|
|
|
|
sendCompletion(error, outgoingMessage);
|
|
|
|
messageSender:self.messageSender
|
|
|
|
}];
|
|
|
|
success:^{
|
|
|
|
} else {
|
|
|
|
sendCompletion(nil, outgoingMessage);
|
|
|
|
outgoingMessage = [ThreadUtil sendMessageWithAttachment:self.attachment
|
|
|
|
}
|
|
|
|
inThread:self.thread
|
|
|
|
failure:^(NSError *_Nonnull error) {
|
|
|
|
messageSender:self.messageSender
|
|
|
|
sendCompletion(error, outgoingMessage);
|
|
|
|
completion:^(NSError *_Nullable error) {
|
|
|
|
}];
|
|
|
|
sendCompletion(error, outgoingMessage);
|
|
|
|
return;
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
outgoingMessage = [ThreadUtil sendMessageWithAttachment:self.attachment
|
|
|
|
|
|
|
|
inThread:self.thread
|
|
|
|
|
|
|
|
messageSender:self.messageSender
|
|
|
|
|
|
|
|
completion:^(NSError *_Nullable error) {
|
|
|
|
|
|
|
|
sendCompletion(error, outgoingMessage);
|
|
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
}];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|