Skip to content

Commit

Permalink
perf(mail): perform IMAP STATUS command to fetch unseen msgs count
Browse files Browse the repository at this point in the history
  • Loading branch information
cgx committed Feb 15, 2022
1 parent b243887 commit 0e20bbc
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions SoObjects/Mailer/SOGoMailFolder.m
@@ -1,5 +1,5 @@
/*
Copyright (C) 2009-2021 Inverse inc.
Copyright (C) 2009-2022 Inverse inc.
Copyright (C) 2004-2005 SKYRIX Software AG
This file is part of SOGo.
Expand Down Expand Up @@ -946,26 +946,12 @@ - (NSDictionary *) statusForFlags: (NSArray *) flags
- (unsigned int) unseenCount
{
NSDictionary *imapResult;
NGImap4Connection *connection;
NGImap4Client *client;
EOQualifier *searchQualifier;
NSArray *searchResult;
unsigned int unseen;

connection = [self imap4Connection];
client = [connection client];

if ([connection selectFolder: [self imap4URL]])
{
searchQualifier
= [EOQualifier qualifierWithQualifierFormat: @"flags = %@ AND not flags = %@",
@"unseen", @"deleted"];
imapResult = [client searchWithQualifier: searchQualifier];
searchResult = [[imapResult objectForKey: @"RawResponse"] objectForKey: @"search"];
unseen = [searchResult count];
}
else
unseen = 0;
unseen = 0;
imapResult = [self statusForFlags: [NSArray arrayWithObject: @"unseen"]];
if (imapResult)
unseen = [[imapResult valueForKey: @"unseen"] intValue];

return unseen;
}
Expand Down

0 comments on commit 0e20bbc

Please sign in to comment.