Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-01-24 16:36:29 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-01-24 16:52:07 +0300
commit7942f00f94e236e9bbcf4ce01fa19e46c6de1d80 (patch)
treee4f53ca6c90a4db3c2df75ddf4fbd9a7c862c36e /lib
parent9f254d8a7fd5f64b1ca1169915ba7c5212dafd79 (diff)
Show embedded messages as attachments
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/Attachment.php2
-rwxr-xr-xlib/Controller/MessagesController.php17
-rw-r--r--lib/Model/IMAPMessage.php16
3 files changed, 24 insertions, 11 deletions
diff --git a/lib/Attachment.php b/lib/Attachment.php
index d80a46f3e..616a78f3f 100644
--- a/lib/Attachment.php
+++ b/lib/Attachment.php
@@ -114,7 +114,7 @@ class Attachment {
}
/**
- * @return string
+ * @return string|null
*/
public function getName() {
return $this->mimePart->getName();
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);
}
}
diff --git a/lib/Model/IMAPMessage.php b/lib/Model/IMAPMessage.php
index 30301ebee..714342d6a 100644
--- a/lib/Model/IMAPMessage.php
+++ b/lib/Model/IMAPMessage.php
@@ -263,21 +263,20 @@ class IMAPMessage implements IMessage, JsonSerializable {
*/
private function hasAttachments($part) {
foreach ($part->getParts() as $p) {
- /**
- * @var Horde_Mime_Part $p
- */
+ /** @var Horde_Mime_Part $p */
$filename = $p->getName();
- if (!is_null($p->getContentId())) {
+ if ($p->getContentId() !== null) {
continue;
}
- if (isset($filename)) {
+ // TODO: show embedded messages and don't treat them as attachments
+ if ($p->getType() === 'message/rfc822' || isset($filename)) {
// do not show technical attachments
if (in_array($filename, $this->attachmentsToIgnore)) {
continue;
- } else {
- return true;
}
+
+ return true;
}
if ($this->hasAttachments($p)) {
return true;
@@ -336,7 +335,8 @@ class IMAPMessage implements IMessage, JsonSerializable {
// Any part with a filename is an attachment,
// so an attached text file (type 0) is not mistaken as the message.
$filename = $p->getName();
- if (isset($filename)) {
+ // TODO: show embedded messages and don't treat them as attachments
+ if ($p->getType() === 'message/rfc822' || isset($filename)) {
if (in_array($filename, $this->attachmentsToIgnore)) {
return;
}