Enforce quoted reply edge cases.

pull/1/head
Matthew Chen 7 years ago
parent 4655c74320
commit 76995e4594

@ -647,6 +647,25 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
} else if (action == self.metadataActionSelector) {
return YES;
} else if (action == self.replyActionSelector) {
if ([self.interaction isKindOfClass:[TSOutgoingMessage class]]) {
TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)self.interaction;
if (outgoingMessage.messageState == TSOutgoingMessageStateUnsent
|| outgoingMessage.messageState == TSOutgoingMessageStateAttemptingOut) {
// Don't let users reply to messages which aren't yet delivered to the service.
return NO;
}
} else if ([self.interaction isKindOfClass:[TSIncomingMessage class]]) {
TSIncomingMessage *incomingMessage = (TSIncomingMessage *)self.interaction;
if (incomingMessage.hasAttachments) {
NSString *attachmentId = incomingMessage.attachmentIds.firstObject;
TSAttachment *_Nullable attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId];
if (![attachment isKindOfClass:[TSAttachmentStream class]]) {
// Don't let users reply to attachments which aren't yet downloaded
// (or otherwise missing on disk).
return NO;
}
}
}
return YES;
} else {
return NO;

File diff suppressed because it is too large Load Diff

@ -170,7 +170,8 @@
if (!hasText && !hasAttachment) {
OWSFail(@"%@ quoted message has neither text nor attachment", self.logTag);
return nil;
quotedText = @"";
hasText = YES;
}
return [[OWSQuotedReplyModel alloc] initWithTimestamp:timestamp

@ -347,7 +347,7 @@ NS_ASSUME_NONNULL_BEGIN
}
if (![[NSFileManager defaultManager] fileExistsAtPath:thumbnailPath]) {
OWSFail(@"%@ missing thumbnail for attachmentId: %@", self.logTag, self.uniqueId);
DDLogError(@"%@ missing thumbnail for attachmentId: %@", self.logTag, self.uniqueId);
return nil;
}

Loading…
Cancel
Save