Commit 59563d85 authored by Sebastian Kummer's avatar Sebastian Kummer

ZO-83 handle KOP forward/reply flags in SendMail request processor, send

email when replacemime is set even if fwmessage (source message) can not
be opened.
parent 800eb79a
......@@ -436,29 +436,6 @@ class BackendZarafa implements IBackend, ISearchProvider {
return false;
}
// Acacia ZO-6: grep for the OL header and set flags accordingly.
// The header has the values verb/message-source-key/folder-source-key
if (preg_match("/X-Push-Flags: (\d{3})\/([\da-f]+)\/([\da-f]+)/i", $sm->mime, $ol_flags)) {
// "reply" and "reply-all" are handled as "reply"
if ($ol_flags[1] == 102 || $ol_flags[1] == 103) {
$sm->replyflag = true;
$sm->forwardflag = false;
}
else if ($ol_flags[1] == 104) {
$sm->replyflag = false;
$sm->forwardflag = true;
}
// set source folder+item and replacemime
if (!isset($sm->source)) {
$sm->source = new SyncSendMailSource();
}
$sm->source->itemid = $ol_flags[2];
$sm->source->folderid = $ol_flags[3];
$sm->replacemime = true;
ZLog::Write(LOGLEVEL_DEBUG, "ZarafaBackend->SendMail(): Outlook support: overwrite reply/forward flag, set parent-id and item-id, replacemime-do not attach original message.");
}
// delayed logging to log to potentially log the parameters set for ZO-6
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ZarafaBackend->SendMail(): RFC822: %d bytes forward-id: '%s' reply-id: '%s' parent-id: '%s' SaveInSent: '%s' ReplaceMIME: '%s'",
strlen($sm->mime), Utils::PrintAsString($sm->forwardflag), Utils::PrintAsString($sm->replyflag),
......@@ -541,9 +518,7 @@ class BackendZarafa implements IBackend, ISearchProvider {
if ($entryid)
$fwmessage = mapi_msgstore_openentry($this->store, $entryid);
if(!isset($fwmessage) || !$fwmessage)
throw new StatusException(sprintf("ZarafaBackend->SendMail(): Could not open message id '%s' in folder id '%s' to be replied/forwarded: 0x%X", $sm->source->itemid, $sm->source->folderid, mapi_last_hresult()), SYNC_COMMONSTATUS_ITEMNOTFOUND);
if (isset($fwmessage) && $fwmessage) {
// update icon and last_verb when forwarding or replying message
// reply-all (verb 103) is not supported, as we cannot really detect this case
if ($sm->forwardflag) {
......@@ -613,6 +588,13 @@ class BackendZarafa implements IBackend, ISearchProvider {
}
}
}
else {
// no fwmessage could be opened and we need it because we do not replace mime
if (!isset($sm->replacemime) || $sm->replacemime == false) {
throw new StatusException(sprintf("ZarafaBackend->SendMail(): Could not open message id '%s' in folder id '%s' to be replied/forwarded: 0x%X", $sm->source->itemid, $sm->source->folderid, mapi_last_hresult()), SYNC_COMMONSTATUS_ITEMNOTFOUND);
}
}
}
mapi_setprops($mapimessage, $mapiprops);
mapi_message_savechanges($mapimessage);
......
......@@ -87,6 +87,28 @@ class SendMail extends RequestProcessor {
// no wbxml output is provided, only a http OK
$sm->saveinsent = Request::GetGETSaveInSent();
}
// KOP ZO-6: grep for the OL header and set flags accordingly.
// The header has the values verb/message-source-key/folder-source-key
if (preg_match("/X-Push-Flags: (\d{3})\/([\da-f]+)\/([\da-f]+)/i", $sm->mime, $ol_flags)) {
// "reply" and "reply-all" are handled as "reply"
if ($ol_flags[1] == 102 || $ol_flags[1] == 103) {
$reply = true;
}
else if ($ol_flags[1] == 104) {
$forward = true;
}
// set source folder+item and replacemime
if (!isset($sm->source)) {
$sm->source = new SyncSendMailSource();
}
$sm->source->itemid = $ol_flags[2];
$sm->source->folderid = $ol_flags[3];
$sm->replacemime = true;
ZLog::Write(LOGLEVEL_DEBUG, "SendMail(): KOP support: overwrite reply/forward flag, set parent-id and item-id, replacemime - original message should not be attached.");
}
// Check if it is a reply or forward. Two cases are possible:
// 1. Either $smartreply or $smartforward are set after reading WBXML
// 2. Either $reply or $forward are set after geting the request parameters
......@@ -111,10 +133,10 @@ class SendMail extends RequestProcessor {
$sm->forwardflag = true;
if (!isset($sm->source->folderid))
ZLog::Write(LOGLEVEL_ERROR, sprintf("No parent folder id while replying or forwarding message:'%s'", (($reply) ? $reply : $forward)));
ZLog::Write(LOGLEVEL_ERROR, sprintf("SendMail(): No parent folder id while replying or forwarding message:'%s'", (($reply) ? $reply : $forward)));
}
self::$topCollector->AnnounceInformation(sprintf("Sending email with %d bytes", strlen($sm->mime)), true);
self::$topCollector->AnnounceInformation(sprintf("SendMail(): Sending email with %d bytes", strlen($sm->mime)), true);
try {
$status = self::$backend->SendMail($sm);
......
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