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/Model
diff options
context:
space:
mode:
authorCyrille Bollu <cyr.debian@bollu.be>2021-03-17 16:24:39 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2021-03-25 19:22:34 +0300
commit9dfd838ddace41d56638b19ef50949b5398e6035 (patch)
treeb4c08fddff9dfed0edb89a0100b24102bbb0f87e /lib/Model
parentad23556f7bb6a8a3516d37997d62d88cd13588ca (diff)
Uses Horde_Mime_Part->isAttachment() as much as possible.
Creates a new 'inlineAttachments' property for IMAPMessages to hold those 'inline attachments' (that's MIME parts having their content-disposition header set to 'inline') Signed-off-by: Cyrille Bollu <cyr.debian@bollu.be> Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/Model')
-rw-r--r--lib/Model/IMAPMessage.php44
1 files changed, 23 insertions, 21 deletions
diff --git a/lib/Model/IMAPMessage.php b/lib/Model/IMAPMessage.php
index 24743ef44..aeb77267c 100644
--- a/lib/Model/IMAPMessage.php
+++ b/lib/Model/IMAPMessage.php
@@ -107,6 +107,7 @@ class IMAPMessage implements IMessage, JsonSerializable {
public $htmlMessage = '';
public $plainMessage = '';
public $attachments = [];
+ public $inlineAttachments = [];
private $loadHtmlMessage = false;
private $hasHtmlMessage = false;
@@ -327,19 +328,7 @@ class IMAPMessage implements IMessage, JsonSerializable {
*/
private function hasAttachments($part) {
foreach ($part->getParts() as $p) {
- /** @var Horde_Mime_Part $p */
- $filename = $p->getName();
-
- if ($p->getContentId() !== null) {
- continue;
- }
- // 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;
- }
-
+ if ($p->isAttachment() || $p->getType() === 'message/rfc822') {
return true;
}
if ($this->hasAttachments($p)) {
@@ -402,23 +391,36 @@ class IMAPMessage implements IMessage, JsonSerializable {
* @return void
*/
private function getPart(Horde_Mime_Part $p, $partNo): void {
- // ATTACHMENT
- // Any part with a filename is an attachment,
- // so an attached text file (type 0) is not mistaken as the message.
+ // Regular attachments
+ if ($p->isAttachment() || $p->getType() === 'message/rfc822') {
+ $this->attachments[] = [
+ 'id' => $p->getMimeId(),
+ 'messageId' => $this->messageId,
+ 'fileName' => $p->getName(),
+ 'mime' => $p->getType(),
+ 'size' => $p->getBytes(),
+ 'cid' => $p->getContentId(),
+ 'disposition' => $p->getDisposition()
+ ];
+ return;
+ }
+
+ // Inline attachments
+ // Horde doesn't consider parts with content-disposition set to inline as
+ // attachment so we need to use another way to get them.
+ // We use these inline attachments to render a message's html body in $this->getHtmlBody()
$filename = $p->getName();
- // 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;
}
- $this->attachments[] = [
+ $this->inlineAttachments[] = [
'id' => $p->getMimeId(),
'messageId' => $this->messageId,
'fileName' => $filename,
'mime' => $p->getType(),
'size' => $p->getBytes(),
- 'cid' => $p->getContentId(),
- 'disposition' => $p->getDisposition()
+ 'cid' => $p->getContentId()
];
return;
}
@@ -507,7 +509,7 @@ class IMAPMessage implements IMessage, JsonSerializable {
return $this->htmlService->sanitizeHtmlMailBody($this->htmlMessage, [
'id' => $id,
], function ($cid) {
- $match = array_filter($this->attachments,
+ $match = array_filter($this->inlineAttachments,
function ($a) use ($cid) {
return $a['cid'] === $cid;
});