]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix calendar emails to be outlook compatible 36118/head
authorAnna Larch <anna@nextcloud.com>
Mon, 20 Feb 2023 17:57:56 +0000 (18:57 +0100)
committerAnna Larch <anna@nextcloud.com>
Tue, 21 Feb 2023 13:37:11 +0000 (14:37 +0100)
Signed-off-by: Anna Larch <anna@nextcloud.com>
apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
lib/private/Mail/Message.php
lib/public/Mail/IMessage.php

index d4c2976fc1a586cd8f5995ee5c5f63839974f59a..bbe6b1ec740381ffdd8dab41474c39201e4bb035 100644 (file)
@@ -285,14 +285,12 @@ class IMipPlugin extends SabreIMipPlugin {
 
                $message->useTemplate($template);
 
-               $vCalendar = $this->imipService->generateVCalendar($iTipMessage, $vEvent);
-
-               $attachment = $this->mailer->createAttachment(
-                       $vCalendar->serialize(),
+               $itip_msg = $iTipMessage->message->serialize();
+               $message->attachInline(
+                               $itip_msg,
                        'event.ics',
-                       'text/calendar; method=' . $iTipMessage->method
+                               'text/calendar; method=' . $iTipMessage->method,
                );
-               $message->attach($attachment);
 
                try {
                        $failed = $this->mailer->send($message);
index 01beefcc6d6e234c425540ded7523fdb2c130c32..35d6f96d33acb7372a24af889468612b18ba6f6e 100644 (file)
@@ -75,6 +75,22 @@ class Message implements IMessage {
                return $this;
        }
 
+       /**
+        * Can be used to "attach content inline" as message parts with specific MIME type and encoding.
+        * {@inheritDoc}
+        * @since 26.0.0
+        */
+       public function attachInline(string $body, string $name, string $contentType = null): IMessage {
+               # To be sure this works with iCalendar messages, we encode with 8bit instead of
+               # quoted-printable encoding. We save the current encoder, replace the current
+               # encoder with an 8bit encoder and after we've finished, we reset the encoder
+               # to the previous one. Originally intended to be added after the message body,
+               # as it is curently unknown if all mail clients handle this properly if added
+               # before.
+               $this->symfonyEmail->embed($body, $name, $contentType);
+               return $this;
+       }
+
        /**
         * Converts the [['displayName' => 'email'], ['displayName2' => 'email2']] arrays to valid Adresses
         *
index 35a67bc4bb81a63be4669bce760c1181ef85d4d9..b3cc86839f11eee9eb4f61e44da4df717507ce26 100644 (file)
@@ -39,6 +39,18 @@ interface IMessage {
         */
        public function attach(IAttachment $attachment): IMessage;
 
+       /**
+        * Can be used to "attach content inline" as message parts with specific MIME type and encoding.
+        *
+        * @param string $body body of the MIME part
+        * @param string $name the file name
+        * @param string|null $contentType MIME Content-Type (e.g. text/plain or text/calendar)
+        *
+        * @return IMessage
+        * @since 26.0.0
+        */
+       public function attachInline(string $body, string $name, string $contentType = null): IMessage;
+
        /**
         * Set the from address of this message.
         *