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,8 +155,15 @@ 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;
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.
@ -168,6 +175,7 @@ NS_ASSUME_NONNULL_BEGIN
areAllAttachmentsDownloaded = areAllAttachmentsDownloaded && attachment.isDownloaded;
if (!areAllAttachmentsDownloaded) break;
}
}
if (!areAllAttachmentsDownloaded) {
return;

Loading…
Cancel
Save