(fix) use the supplied Sieve creds to fetch the IMAP4 separator (fixes #4846)

This commit is contained in:
Ludovic Marcotte
2019-10-25 13:31:13 -04:00
parent 2d5d1b4297
commit 34fcfe024b
3 changed files with 32 additions and 5 deletions

13
NEWS
View File

@@ -1,3 +1,16 @@
4.1.1 (2019-XX-XX)
------------------
New features
-
Enhancements
-
Bug fixes
- [core] use the supplied Sieve creds to fetch the IMAP4 separator (#4846)
4.1.0 (2019-10-24)
------------------

View File

@@ -1,6 +1,6 @@
/* SOGoSieveManager.h - this file is part of SOGo
*
* Copyright (C) 2010-2014 Inverse inc.
* Copyright (C) 2010-2019 Inverse inc.
*
* Author: Inverse <info@inverse.ca>
*
@@ -41,7 +41,8 @@
+ (id) sieveManagerForUser: (SOGoUser *) user;
- (id) initForUser: (SOGoUser *) newUser;
- (NSString *) sieveScriptWithRequirements: (NSMutableArray *) newRequirements;
- (NSString *) sieveScriptWithRequirements: (NSMutableArray *) newRequirements
delimiter: (NSString *) delimiter;
- (NSString *) lastScriptError;
- (NGSieveClient *) clientForAccount: (SOGoMailAccount *) theAccount;

View File

@@ -32,6 +32,8 @@
#import <SOGo/SOGoTextTemplateFile.h>
#import <NGExtensions/NSObject+Logs.h>
#import <NGImap4/NGImap4Connection.h>
#import <NGImap4/NGImap4Client.h>
#import <NGImap4/NGSieveClient.h>
#import "../Mailer/SOGoMailAccount.h"
@@ -450,7 +452,6 @@ static NSString *sieveScriptName = @"sogo";
{
NSString *sieveAction, *method, *requirement, *argument, *flag, *mailbox;
NSDictionary *mailLabels;
SOGoDomainDefaults *dd;
sieveAction = nil;
@@ -486,7 +487,6 @@ static NSString *sieveScriptName = @"sogo";
}
else if ([method isEqualToString: @"fileinto"])
{
dd = [user domainDefaults];
mailbox
= [[argument componentsSeparatedByString: @"/"]
componentsJoinedByString: delimiter];
@@ -789,6 +789,7 @@ static NSString *sieveScriptName = @"sogo";
SOGoUserDefaults *ud;
SOGoDomainDefaults *dd;
NGSieveClient *client;
NGImap4Client *imapClient;
NSString *filterScript, *v;
BOOL b, dateCapability;
unsigned int now;
@@ -821,9 +822,21 @@ static NSString *sieveScriptName = @"sogo";
//
script = [NSMutableString string];
// We grab the IMAP4 delimiter using the supplied username/password
if (thePassword)
{
imapClient = [NGImap4Client clientWithURL: [theAccount imap4URL]];
[imapClient login: theUsername password: thePassword];
}
else
imapClient = [[theAccount imap4Connection] client];
if (![imapClient delimiter])
[imapClient list: @"INBOX" pattern: @""];
// We first handle filters
filterScript = [self sieveScriptWithRequirements: req
delimiter: [theAccount imap4Separator]];
delimiter: [imapClient delimiter]];
if (filterScript)
{
if ([filterScript length])