diff --git a/src/app/DataMigrator/EWS/Email.php b/src/app/DataMigrator/EWS/Email.php index 330d1c28..621daf5b 100644 --- a/src/app/DataMigrator/EWS/Email.php +++ b/src/app/DataMigrator/EWS/Email.php @@ -1,102 +1,59 @@ 'calendar:UID']; return $request; } /** * Process event object */ protected function convertItem(Type $item) { // Initialize $this->itemId (for some unit tests) $this->getUID($item); // Decode MIME content $mime = base64_decode((string) $item->getMimeContent()); - $itemId = implode("\r\n ", str_split($this->itemId, 75 - strlen('X-MS-ID:'))); - - - // $ical = preg_replace('/\r\nBEGIN:VEVENT\r\n/', "\r\nBEGIN:VEVENT\r\nX-MS-ID:{$itemId}\r\n", $ical, 1); - // - // // TODO: replace source email with destination email address in ORGANIZER/ATTENDEE - // - // // Inject attachment bodies into the iCalendar content - // // Calendar event attachments are exported as: - // // ATTACH:CID:81490FBA13A3DC2BF071B894C96B44BA51BEAAED@eurprd05.prod.outlook.com - // if ($item->getHasAttachments()) { - // // FIXME: I've tried hard and no matter what ContentId property is always empty - // // This means we can't match the CID from iCalendar with the attachment. - // // That's why we'll just remove all ATTACH:CID:... occurrences - // // and inject attachments to the main event - // $ical = preg_replace('/\r\nATTACH:CID:[^\r]+\r\n(\r\n [^\r\n]*)?/', '', $ical); - // - // foreach ((array) $item->getAttachments()->getFileAttachment() as $attachment) { - // $_attachment = $this->getAttachment($attachment); - // - // $ctype = $_attachment->getContentType(); - // $body = $_attachment->getContent(); - // - // // It looks like Exchange may have an issue with plain text files. - // // We'll skip empty files - // if (!strlen($body)) { - // continue; - // } - // - // // FIXME: This is imo inconsistence on php-ews side that MimeContent - // // is base64 encoded, but Content isn't - // // TODO: We should not do it in memory to not exceed the memory limit - // $body = base64_encode($body); - // $body = rtrim(chunk_split($body, 74, "\r\n "), ' '); - // - // // Inject the attachment at the end of the first VEVENT block - // // TODO: We should not do it in memory to not exceed the memory limit - // $append = "ATTACH;VALUE=BINARY;ENCODING=BASE64;FMTTYPE={$ctype}:\r\n {$body}"; - // $pos = strpos($ical, "\r\nEND:VEVENT"); - // $ical = substr_replace($ical, $append, $pos + 2, 0); - // } - // } - return $mime; } /** * Get Item UID (Generate a new one if needed) */ protected function getUID(Type $item): string { // Only appointments have UID property $this->uid = $item->getUID(); // This also sets $this->itemId; return parent::getUID($item); } }