From 2c6cd53ea76965464eb810bc13dada3d51b1406d Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Fri, 14 Jan 2022 10:13:20 -0500 Subject: [PATCH] fix(mail): improve handling of QRESYNC responses --- SoObjects/Mailer/SOGoMailFolder.m | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index 02093f3cd..f226145c7 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -2180,11 +2180,12 @@ static NSInteger _compareFetchResultsByUID (id entry1, id entry2, NSArray *uids) if ([self imap4Connection]) { NSDictionary *result; - unsigned int modseq, uid; + unsigned int uid; + uint64_t modseq; uid = [theId intValue]; result = [[imap4 client] fetchModseqForUid: uid]; - modseq = [[[[result objectForKey: @"RawResponse"] objectForKey: @"fetch"] objectForKey: @"modseq"] intValue]; + modseq = [[[[result objectForKey: @"RawResponse"] objectForKey: @"fetch"] objectForKey: @"modseq"] longLongValue]; if (modseq < 1) modseq = 1; @@ -2205,14 +2206,16 @@ static NSInteger _compareFetchResultsByUID (id entry1, id entry2, NSArray *uids) { NSString *folderName; NSDictionary *result; + NSArray *keys; folderName = [imap4 imap4FolderNameForURL: [self imap4URL]]; [[imap4 client] unselect]; result = [[imap4 client] select: folderName]; - - tag = [NSString stringWithFormat: @"%@-%@", [result objectForKey: @"uidnext"], [result objectForKey: @"highestmodseq"]]; + keys = [result allKeys]; + if ([keys containsObject: @"uidnext"] && [keys containsObject: @"highestmodseq"]) + tag = [NSString stringWithFormat: @"%@-%@", [result objectForKey: @"uidnext"], [result objectForKey: @"highestmodseq"]]; } return tag;