Commit 13dba524 authored by Manfred Kutas's avatar Manfred Kutas

ZP-990 Detect case that KOE is sending changed categories back and

ignore it if categories are the same on the server and in outlook.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 5552c219
...@@ -396,15 +396,6 @@ class ImportChangesICS implements IImportChanges { ...@@ -396,15 +396,6 @@ class ImportChangesICS implements IImportChanges {
list(, $sk) = MAPIUtils::SplitMessageId($id); list(, $sk) = MAPIUtils::SplitMessageId($id);
$props[PR_SOURCE_KEY] = hex2bin($sk); $props[PR_SOURCE_KEY] = hex2bin($sk);
// KOE ZP-990: OL updates the deleted category which causes a race condition if more than one KOE is connected to that user
if(ZPush::GetDeviceManager()->IsKoe() && KOE_CAPABILITY_RECEIVEFLAGS && !isset($message->flag) && isset($message->categories)) {
// check if the categories changed
if(true) {
ZLog::Write(LOGLEVEL_DEBUG, "ImportChangesICS->ImportMessageChange('%s'): KOE reply back of categories. Ignoreing incoming update.");
return $id;
}
}
// on editing an existing message, check if it is in the synchronization interval // on editing an existing message, check if it is in the synchronization interval
if (!$this->isMessageInSyncInterval($sk)) if (!$this->isMessageInSyncInterval($sk))
throw new StatusException(sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Message is outside the sync interval. Data not saved.", $id, get_class($message)), SYNC_STATUS_SYNCCANNOTBECOMPLETED); throw new StatusException(sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Message is outside the sync interval. Data not saved.", $id, get_class($message)), SYNC_STATUS_SYNCCANNOTBECOMPLETED);
...@@ -424,6 +415,18 @@ class ImportChangesICS implements IImportChanges { ...@@ -424,6 +415,18 @@ class ImportChangesICS implements IImportChanges {
ZLog::Write(LOGLEVEL_INFO, sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Conflict detected. Data from PIM will be dropped! Object was deleted on server.", $id, get_class($message))); ZLog::Write(LOGLEVEL_INFO, sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Conflict detected. Data from PIM will be dropped! Object was deleted on server.", $id, get_class($message)));
return false; return false;
} }
// KOE ZP-990: OL updates the deleted category which causes a race condition if more than one KOE is connected to that user
if(ZPush::GetDeviceManager()->IsKoe() && KOE_CAPABILITY_RECEIVEFLAGS && !isset($message->flag) && isset($message->categories)) {
// check if the categories changed
$mapiCategories = $this->mapiprovider->GetMessageCategories($props[PR_PARENT_SOURCE_KEY], $props[PR_SOURCE_KEY]);
if( (empty($message->categories) && empty($mapiCategories)) ||
(is_array($mapiCategories) && count(array_diff($mapiCategories, $message->categories)) == 0 && count(array_diff($message->categories, $mapiCategories)) == 0)) {
ZLog::Write(LOGLEVEL_DEBUG, "ImportChangesICS->ImportMessageChange(): KOE update of flag categories. Ignoring incoming update.");
return $id;
}
}
} }
else else
$flags = SYNC_NEW_MESSAGE; $flags = SYNC_NEW_MESSAGE;
......
...@@ -2778,4 +2778,29 @@ class MAPIProvider { ...@@ -2778,4 +2778,29 @@ class MAPIProvider {
} }
return $this->inboxProps; return $this->inboxProps;
} }
/**
* Returns categories for a message.
*
* @param binary $parentsourcekey
* @param binary $sourcekey
*
* @access public
* @return array or false on failure
*/
public function GetMessageCategories($parentsourcekey, $sourcekey) {
$entryid = mapi_msgstore_entryidfromsourcekey($this->store, $parentsourcekey, $sourcekey);
if (!$entryid) {
ZLog::Write(LOGLEVEL_INFO, sprintf("MAPIProvider->GetMessageCategories(): Couldn't retrieve message, sourcekey: '%s', parentsourcekey: '%s'", bin2hex($sourcekey), bin2hex($parentsourcekey)));
return false;
}
$mapimessage = mapi_msgstore_openentry($this->store, $entryid);
$emailMapping = MAPIMapping::GetEmailMapping();
$emailMapping = array("categories" => $emailMapping["categories"]);
$messageCategories = $this->getProps($mapimessage, $emailMapping);
if (isset($messageCategories[$emailMapping["categories"]]) && is_array($messageCategories[$emailMapping["categories"]])) {
return $messageCategories[$emailMapping["categories"]];
}
return false;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment