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
diff options
context:
space:
mode:
-rw-r--r--lib/Attachment.php2
-rwxr-xr-xlib/Controller/MessagesController.php17
-rw-r--r--lib/Model/IMAPMessage.php16
-rw-r--r--src/components/Composer.vue3
-rw-r--r--src/components/MessageAttachment.vue17
-rw-r--r--src/components/MessageAttachments.vue1
-rw-r--r--tests/Unit/Controller/MessagesControllerTest.php2
7 files changed, 44 insertions, 14 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;
}
diff --git a/src/components/Composer.vue b/src/components/Composer.vue
index eb01617bd..d6af9ff4a 100644
--- a/src/components/Composer.vue
+++ b/src/components/Composer.vue
@@ -14,6 +14,7 @@
:hide-selected="true"
:custom-label="formatAliases"
:placeholder="t('mail', 'Select account')"
+ :clear-on-select="false"
@keyup="onInputChanged"
/>
</div>
@@ -31,6 +32,7 @@
track-by="email"
:multiple="true"
:placeholder="t('mail', 'Contact or email address …')"
+ :clear-on-select="false"
:show-no-options="false"
@keyup="onInputChanged"
@tag="onNewToAddr"
@@ -53,6 +55,7 @@
track-by="email"
:multiple="true"
:placeholder="t('mail', '')"
+ :clear-on-select="false"
:show-no-options="false"
@keyup="onInputChanged"
@tag="onNewCcAddr"
diff --git a/src/components/MessageAttachment.vue b/src/components/MessageAttachment.vue
index d720429a9..6b8a8719e 100644
--- a/src/components/MessageAttachment.vue
+++ b/src/components/MessageAttachment.vue
@@ -24,7 +24,7 @@
<img v-if="isImage" class="mail-attached-image" :src="url" />
<img class="attachment-icon" :src="mimeUrl" />
<span class="attachment-name" :title="label"
- >{{ fileName }}
+ >{{ name }}
<span class="attachment-size">({{ humanReadable(size) }})</span>
</span>
<button
@@ -78,7 +78,7 @@ export default {
},
fileName: {
type: String,
- required: true,
+ required: false,
},
url: {
type: String,
@@ -88,6 +88,10 @@ export default {
type: Number,
required: true,
},
+ mime: {
+ type: String,
+ required: true,
+ },
mimeUrl: {
type: String,
required: true,
@@ -110,7 +114,16 @@ export default {
}
},
computed: {
+ name() {
+ if (this.mime === 'message/rfc822') {
+ return t('mail', 'Embedded message')
+ }
+ return this.fileName
+ },
label() {
+ if (this.mime === 'message/rfc822') {
+ return t('mail', 'Embedded message') + ' (' + formatFileSize(this.size) + ')'
+ }
return this.fileName + ' (' + formatFileSize(this.size) + ')'
},
calendarMenuEntries() {
diff --git a/src/components/MessageAttachments.vue b/src/components/MessageAttachments.vue
index ae0abb87d..589184813 100644
--- a/src/components/MessageAttachments.vue
+++ b/src/components/MessageAttachments.vue
@@ -31,6 +31,7 @@
:url="attachment.downloadUrl"
:is-image="attachment.isImage"
:is-calendar-event="attachment.isCalendarEvent"
+ :mime="attachment.mime"
:mime-url="attachment.mimeUrl"
/>
</div>
diff --git a/tests/Unit/Controller/MessagesControllerTest.php b/tests/Unit/Controller/MessagesControllerTest.php
index fee9d4c36..1178a03c4 100644
--- a/tests/Unit/Controller/MessagesControllerTest.php
+++ b/tests/Unit/Controller/MessagesControllerTest.php
@@ -235,7 +235,7 @@ class MessagesControllerTest extends TestCase {
$this->attachment->expects($this->once())
->method('getContents')
->will($this->returnValue($contents));
- $this->attachment->expects($this->once())
+ $this->attachment->expects($this->any())
->method('getName')
->will($this->returnValue($name));
$this->attachment->expects($this->once())