Commit 3bdca761 authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #308 in ZP/z-push from...

Merge pull request #308 in ZP/z-push from bugfix/ZP-990-koe-race-condition-when-connecting to develop

* commit '13dba524':
  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.
  ZP-990 Detect case that KOE is sending changed categories back.
parents fea6d7f8 13dba524
......@@ -415,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)));
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
$flags = SYNC_NEW_MESSAGE;
......
......@@ -2785,4 +2785,29 @@ class MAPIProvider {
}
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