From 7942f00f94e236e9bbcf4ce01fa19e46c6de1d80 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Fri, 24 Jan 2020 14:36:29 +0100 Subject: Show embedded messages as attachments Signed-off-by: Christoph Wurst --- lib/Controller/MessagesController.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'lib/Controller/MessagesController.php') diff --git a/lib/Controller/MessagesController.php b/lib/Controller/MessagesController.php index 22b5d7b03..804022b96 100755 --- a/lib/Controller/MessagesController.php +++ b/lib/Controller/MessagesController.php @@ -292,8 +292,21 @@ class MessagesController extends Controller { $attachment = $mailBox->getAttachment($messageId, $attachmentId); + // Body party and embedded messages do not have a name + if ($attachment->getName() === null) { + return new AttachmentDownloadResponse( + $attachment->getContents(), + $this->l10n->t('Embedded message %s', [ + $attachmentId, + ]) . '.eml', + $attachment->getType() + ); + } return new AttachmentDownloadResponse( - $attachment->getContents(), $attachment->getName(), $attachment->getType()); + $attachment->getContents(), + $attachment->getName(), + $attachment->getType() + ); } /** @@ -452,7 +465,7 @@ class MessagesController extends Controller { * @return boolean */ private function attachmentIsCalendarEvent(array $attachment): bool { - return in_array($attachment['mime'], ['text/calendar', 'application/ics'], true); + return in_array($attachment['mime'], ['text/calendar', 'application/ics'], true); } } -- cgit v1.2.3