mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-03-22 23:02:43 +00:00
Avoid creating duplicates in Outlook on MoveItems (#2650)
This commit is contained in:
@@ -64,6 +64,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#import <EOControl/EOQualifier.h>
|
||||
|
||||
#import <SOGo/NSArray+DAV.h>
|
||||
#import <SOGo/SOGoCache.h>
|
||||
#import <SOGo/NSDictionary+DAV.h>
|
||||
#import <SOGo/SOGoDAVAuthenticator.h>
|
||||
#import <SOGo/SOGoDomainDefaults.h>
|
||||
@@ -567,8 +568,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
default:
|
||||
{
|
||||
NSMutableArray *addedOrChangedMessages;
|
||||
NSString *uid, *command, *key;
|
||||
SOGoMailObject *mailObject;
|
||||
NSString *uid, *command;
|
||||
NSDictionary *aMessage;
|
||||
NSArray *allMessages;
|
||||
int deleted_count;
|
||||
@@ -618,6 +619,20 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
uid = [[[aMessage allKeys] lastObject] stringValue];
|
||||
command = [[aMessage allValues] lastObject];
|
||||
|
||||
// We check for Outlook stupidity to avoid creating duplicates - see the comment
|
||||
// in SOGoActiveSyncDispatcher.m: -processMoveItems:inResponse: for more details.
|
||||
key = [NSString stringWithFormat: @"%@+%@+%@+%@",
|
||||
[[context activeUser] login],
|
||||
[context objectForKey: @"DeviceType"],
|
||||
[theCollection displayName],
|
||||
uid];
|
||||
|
||||
if ([[SOGoCache sharedCache] valueForKey: key])
|
||||
{
|
||||
[[SOGoCache sharedCache] removeValueForKey: key];
|
||||
command = @"changed";
|
||||
}
|
||||
|
||||
if ([command isEqualToString: @"added"])
|
||||
[s appendString: @"<Add xmlns=\"AirSync:\">"];
|
||||
else
|
||||
|
||||
@@ -76,6 +76,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <SOGo/NSArray+DAV.h>
|
||||
#import <SOGo/NSDictionary+DAV.h>
|
||||
#import <SOGo/SOGoCache.h>
|
||||
#import <SOGo/SOGoDAVAuthenticator.h>
|
||||
#import <SOGo/SOGoDomainDefaults.h>
|
||||
#import <SOGo/SOGoMailer.h>
|
||||
@@ -880,10 +881,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
NSDictionary *response;
|
||||
NSString *v;
|
||||
|
||||
// userFolder = [[context activeUser] homeFolderInContext: context];
|
||||
// accountsFolder = [userFolder lookupName: @"Mail" inContext: context acquire: NO];
|
||||
// currentFolder = [accountsFolder lookupName: @"0" inContext: context acquire: NO];
|
||||
|
||||
currentCollection = [self collectionFromId: srcFolderId type: srcFolderType];
|
||||
|
||||
@@ -925,6 +922,28 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
NSMutableString *s;
|
||||
NSData *d;
|
||||
|
||||
//
|
||||
// If the MoveItems operation is initiated by an Outlook client, we save the "deviceType+dstMessageId" to use it later in order to
|
||||
// modify the Sync command from "add" to "change" (see SOGoActiveSyncDispatcher+Sync.m: -processSyncGetChanges: ...).
|
||||
// This is to avoid Outlook creating dupes when moving messages across folfers.
|
||||
//
|
||||
if ([[context objectForKey: @"DeviceType"] isEqualToString: @"WindowsOutlook15"])
|
||||
{
|
||||
NSString *key;
|
||||
|
||||
// The key must be pretty verbose. We use the <uid>+<DeviceType>+<target folder>+<DstMsgId>
|
||||
key = [NSString stringWithFormat: @"%@+%@+%@+%@",
|
||||
[[context activeUser] login],
|
||||
[context objectForKey: @"DeviceType"],
|
||||
dstFolderId,
|
||||
dstMessageId];
|
||||
|
||||
|
||||
[[SOGoCache sharedCache] setValue: @"MovedItem"
|
||||
forKey: key];
|
||||
}
|
||||
|
||||
|
||||
// Everything is alright, lets return the proper response. "Status == 3" means success.
|
||||
s = [NSMutableString string];
|
||||
|
||||
@@ -1522,9 +1541,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
ASSIGN(context, theContext);
|
||||
|
||||
// Get the device ID and "stash" it
|
||||
// Get the device ID, device type and "stash" them
|
||||
deviceId = [[theRequest uri] deviceId];
|
||||
[context setObject: deviceId forKey: @"DeviceId"];
|
||||
[context setObject: [[theRequest uri] deviceType] forKey: @"DeviceType"];
|
||||
|
||||
d = [[theRequest content] wbxml2xml];
|
||||
documentElement = nil;
|
||||
|
||||
Reference in New Issue
Block a user