|
|
|
@ -155,18 +155,26 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
if (_read && readTimestamp >= self.expireStartedAt) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
BOOL isTrusted = YES;
|
|
|
|
|
TSThread* thread = [self threadWithTransaction:transaction];
|
|
|
|
|
if ([thread isKindOfClass:[TSContactThread class]]) {
|
|
|
|
|
TSContactThread* contactThread = (TSContactThread*)thread;
|
|
|
|
|
isTrusted = [[LKStorage shared] getContactWithSessionID:[contactThread contactSessionID] using:transaction].isTrusted;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOL areAllAttachmentsDownloaded = YES;
|
|
|
|
|
for (NSString *attachmentId in self.attachmentIds) {
|
|
|
|
|
TSAttachment *attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId transaction:transaction];
|
|
|
|
|
// If the attachment download failed, we can mark this message as read.
|
|
|
|
|
// Otherwise, this message will never be marked as read.
|
|
|
|
|
if ([attachment isKindOfClass:[TSAttachmentPointer class]]
|
|
|
|
|
&& ((TSAttachmentPointer *)attachment).state == TSAttachmentPointerStateFailed) {
|
|
|
|
|
continue;
|
|
|
|
|
if (isTrusted) {
|
|
|
|
|
for (NSString *attachmentId in self.attachmentIds) {
|
|
|
|
|
TSAttachment *attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId transaction:transaction];
|
|
|
|
|
// If the attachment download failed, we can mark this message as read.
|
|
|
|
|
// Otherwise, this message will never be marked as read.
|
|
|
|
|
if ([attachment isKindOfClass:[TSAttachmentPointer class]]
|
|
|
|
|
&& ((TSAttachmentPointer *)attachment).state == TSAttachmentPointerStateFailed) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
areAllAttachmentsDownloaded = areAllAttachmentsDownloaded && attachment.isDownloaded;
|
|
|
|
|
if (!areAllAttachmentsDownloaded) break;
|
|
|
|
|
}
|
|
|
|
|
areAllAttachmentsDownloaded = areAllAttachmentsDownloaded && attachment.isDownloaded;
|
|
|
|
|
if (!areAllAttachmentsDownloaded) break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!areAllAttachmentsDownloaded) {
|
|
|
|
|