fix an issue where untrusted contact's media message will never be marked as read

pull/507/head
ryanzhao 4 years ago
parent 140676fdaf
commit dcd3997a78

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

Loading…
Cancel
Save