Skip to content

Commit 5fe5275

Browse files
fix: allow to send attachment without setting disposition
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
1 parent 35c164b commit 5fe5275

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lib/Provider/Command/MessageSend.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ public function perform(string $userId, string $serviceId, IMessage $message, ar
6060
// validate that all attachments have a name, type, and contents
6161
$entries = $message->getAttachments();
6262
array_walk($entries, function ($entry) {
63-
if (empty($entry->getName()) || empty($entry->getType()) || empty($entry->getContents())) {
64-
throw new SendException('Invalid Attachment Parameter: MUST contain values for Name, Type and Contents');
63+
if (empty($entry->getType()) || empty($entry->getContents())) {
64+
throw new SendException('Invalid Attachment Parameter: MUST contain values for Type and Contents');
6565
}
6666
});
6767
// retrieve user mail account details

lib/Service/TransmissionService.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
namespace OCA\Mail\Service;
99

10+
use Horde_Mime_Part;
1011
use OCA\Mail\Account;
1112
use OCA\Mail\Address;
1213
use OCA\Mail\AddressList;
@@ -73,20 +74,21 @@ public function getAttachments(LocalMessage $message): array {
7374
* @param array $attachment
7475
* @return \Horde_Mime_Part|null
7576
*/
76-
public function handleAttachment(Account $account, array $attachment): ?\Horde_Mime_Part {
77+
public function handleAttachment(Account $account, array $attachment): ?Horde_Mime_Part {
7778
if (!isset($attachment['id'])) {
7879
$this->logger->warning('ignoring local attachment because its id is unknown');
7980
return null;
8081
}
8182

8283
try {
8384
[$localAttachment, $file] = $this->attachmentService->getAttachment($account->getMailAccount()->getUserId(), (int)$attachment['id']);
84-
$part = new \Horde_Mime_Part();
85+
$part = new Horde_Mime_Part();
8586
$part->setCharset('us-ascii');
86-
$part->setDisposition('attachment');
87-
$part->setName($localAttachment->getFileName());
87+
if (!empty($localAttachment->getFileName())) {
88+
$part->setDisposition('attachment');
89+
$part->setName($localAttachment->getFileName());
90+
}
8891
$part->setContents($file->getContent());
89-
9092
/*
9193
* Horde_Mime_Part.setType takes the mimetype (e.g. text/calendar)
9294
* and discards additional parameters (like method=REQUEST).

0 commit comments

Comments
 (0)