mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-21 11:25:24 +00:00
(fix) refactored code and we now return the unseenCount when fetching uids
This commit is contained in:
@@ -56,6 +56,7 @@
|
||||
- (NSArray *) toManyRelationshipKeys;
|
||||
|
||||
- (NSDictionary *) statusForFlags: (NSArray *) flags;
|
||||
- (unsigned int) unseenCount;
|
||||
|
||||
- (NSException *) deleteUIDs: (NSArray *) uids
|
||||
useTrashFolder: (BOOL *) withTrash
|
||||
|
||||
@@ -801,6 +801,33 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data)
|
||||
return status;
|
||||
}
|
||||
|
||||
- (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;
|
||||
|
||||
return unseen;
|
||||
}
|
||||
|
||||
- (NSArray *) fetchUIDsMatchingQualifier: (id) _q
|
||||
sortOrdering: (id) _so
|
||||
{
|
||||
|
||||
@@ -410,7 +410,7 @@
|
||||
|
||||
- (WOResponse *) copyMessagesAction
|
||||
{
|
||||
NSString *value, *destinationFolder;
|
||||
NSString *destinationFolder;
|
||||
SOGoMailAccount *account;
|
||||
WOResponse *response;
|
||||
SOGoMailFolder *co;
|
||||
@@ -450,7 +450,7 @@
|
||||
NSString *currentMailbox, *currentAccount, *keyForMsgUIDs;
|
||||
NSMutableDictionary *moduleSettings, *threadsCollapsed;
|
||||
NSMutableArray *mailboxThreadsCollapsed;
|
||||
NSString *value, *destinationFolder;
|
||||
NSString *destinationFolder;
|
||||
SOGoUserSettings *us;
|
||||
WOResponse *response;
|
||||
NSDictionary *data;
|
||||
|
||||
@@ -666,6 +666,9 @@
|
||||
[data setObject: uids forKey: @"uids"];
|
||||
[data setObject: [NSNumber numberWithBool: sortByThread] forKey: @"threaded"];
|
||||
|
||||
// We get the unseen count
|
||||
[data setObject: [NSNumber numberWithUnsignedInt: [folder unseenCount]] forKey: @"unseenCount"];
|
||||
|
||||
// We also return the inbox quota
|
||||
account = [folder mailAccountFolder];
|
||||
quota = [account getInboxQuota];
|
||||
@@ -699,6 +702,7 @@
|
||||
* @apiParam {String} [filters.negative] Reverse the condition when true. Defaults to false.
|
||||
*
|
||||
* @apiSuccess (Success 200) {Number} threaded 1 if threading is enabled for the user.
|
||||
* @apiSuccess (Success 200) {Number} unseenCount Number of unread messages
|
||||
* @apiSuccess (Success 200) {Number[]} uids List of uids matching the filters, in the requested order.
|
||||
* @apiSuccess (Success 200) {String[]} headers The first entry are the fields names.
|
||||
* @apiSuccess (Success 200) {Object[]} headers.To Recipients
|
||||
|
||||
@@ -33,9 +33,6 @@
|
||||
#import <NGObjWeb/SoComponent.h>
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
#import <NGExtensions/NSString+misc.h>
|
||||
#import <NGImap4/NGImap4Connection.h>
|
||||
#import <NGImap4/NGImap4Client.h>
|
||||
#import <NGImap4/NSString+Imap4.h>
|
||||
|
||||
#import <Contacts/SOGoContactObject.h>
|
||||
#import <Contacts/SOGoContactGCSList.h>
|
||||
@@ -626,16 +623,12 @@
|
||||
|
||||
- (unsigned int) _unseenCountForFolder: (NSString *) theFolder
|
||||
{
|
||||
EOQualifier *searchQualifier;
|
||||
NSArray *searchResult, *pathComponents;
|
||||
NSDictionary *imapResult;
|
||||
NGImap4Connection *connection;
|
||||
NGImap4Client *client;
|
||||
unsigned int unseen;
|
||||
|
||||
NSArray *pathComponents;
|
||||
SOGoMailAccount *account;
|
||||
SOGoMailFolder *folder;
|
||||
|
||||
unsigned int unseen;
|
||||
|
||||
pathComponents = [theFolder pathComponents];
|
||||
account = [[self clientObject] lookupName: [pathComponents objectAtIndex: 0]
|
||||
inContext: context
|
||||
@@ -645,22 +638,7 @@
|
||||
inContext: context
|
||||
acquire: YES];
|
||||
|
||||
connection = [folder imap4Connection];
|
||||
client = [connection client];
|
||||
|
||||
if ([connection selectFolder: [folder 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;
|
||||
|
||||
return unseen;
|
||||
return [folder unseenCount];
|
||||
}
|
||||
|
||||
- (WOResponse *) unseenCountAction
|
||||
|
||||
@@ -232,7 +232,7 @@
|
||||
if (!_.includes(unseenCountFolders, account.id + '/folderINBOX'))
|
||||
unseenCountFolders.push(account.id + '/folderINBOX');
|
||||
|
||||
_.forEach(account.$mailboxes, function(mailbox) {
|
||||
_.forEach(account.$$flattenMailboxes, function(mailbox) {
|
||||
if (angular.isDefined(mailbox.unseenCount) &&
|
||||
!_.includes(unseenCountFolders, mailbox.id))
|
||||
unseenCountFolders.push(mailbox.id);
|
||||
@@ -241,7 +241,7 @@
|
||||
|
||||
Account.$$resource.post('', 'unseenCount', {mailboxes: unseenCountFolders}).then(function(data) {
|
||||
_.forEach(vm.accounts, function(account) {
|
||||
_.forEach(account.$mailboxes, function(mailbox) {
|
||||
_.forEach(account.$$flattenMailboxes, function(mailbox) {
|
||||
if (data[mailbox.id])
|
||||
mailbox.unseenCount = data[mailbox.id];
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user