Send URLs as text messages.

pull/1/head
Matthew Chen 7 years ago
parent 085975ebe9
commit 9718387af5

@ -220,16 +220,10 @@ 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;
if (!data) {
DDLogError(@"%@ couldn't load data for oversize text attachment", self.logTag);
} else {
NSString *messageText =
[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
outgoingMessage = [ThreadUtil sendMessageWithText:messageText outgoingMessage = [ThreadUtil sendMessageWithText:messageText
inThread:self.thread inThread:self.thread
messageSender:self.messageSender messageSender:self.messageSender
@ -239,16 +233,14 @@ NS_ASSUME_NONNULL_BEGIN
failure:^(NSError *_Nonnull error) { failure:^(NSError *_Nonnull error) {
sendCompletion(error, outgoingMessage); sendCompletion(error, outgoingMessage);
}]; }];
return; } else {
}
}
outgoingMessage = [ThreadUtil sendMessageWithAttachment:self.attachment outgoingMessage = [ThreadUtil sendMessageWithAttachment:self.attachment
inThread:self.thread inThread:self.thread
messageSender:self.messageSender messageSender:self.messageSender
completion:^(NSError *_Nullable error) { completion:^(NSError *_Nullable error) {
sendCompletion(error, outgoingMessage); sendCompletion(error, outgoingMessage);
}]; }];
}
}]; }];
} }

Loading…
Cancel
Save