diff options
-rw-r--r-- | lib/Attachment.php | 2 | ||||
-rwxr-xr-x | lib/Controller/MessagesController.php | 6 | ||||
-rw-r--r-- | lib/Mailbox.php | 4 | ||||
-rw-r--r-- | lib/Model/IMAPMessage.php | 2 | ||||
-rw-r--r-- | lib/Service/IMailBox.php | 4 | ||||
-rw-r--r-- | tests/Unit/Controller/MessagesControllerTest.php | 13 |
6 files changed, 18 insertions, 13 deletions
diff --git a/lib/Attachment.php b/lib/Attachment.php index 7b5760c95..d80a46f3e 100644 --- a/lib/Attachment.php +++ b/lib/Attachment.php @@ -33,7 +33,7 @@ class Attachment { * @param \Horde_Imap_Client_Socket $conn * @param \Horde_Imap_Client_Mailbox $mailBox * @param int $messageId - * @param int $attachmentId + * @param string $attachmentId */ public function __construct($conn, $mailBox, $messageId, $attachmentId) { $this->conn = $conn; diff --git a/lib/Controller/MessagesController.php b/lib/Controller/MessagesController.php index 2e949df28..d4ca2c4a6 100755 --- a/lib/Controller/MessagesController.php +++ b/lib/Controller/MessagesController.php @@ -278,7 +278,7 @@ class MessagesController extends Controller { * @return AttachmentDownloadResponse */ public function downloadAttachment(int $accountId, string $folderId, int $messageId, - int $attachmentId) { + string $attachmentId) { $mailBox = $this->getFolder($accountId, $folderId); $attachment = $mailBox->getAttachment($messageId, $attachmentId); @@ -300,10 +300,10 @@ class MessagesController extends Controller { * @return JSONResponse */ public function saveAttachment(int $accountId, string $folderId, int $messageId, - int $attachmentId, string $targetPath) { + string $attachmentId, string $targetPath) { $mailBox = $this->getFolder($accountId, $folderId); - if ($attachmentId === 0) { + if ($attachmentId === '0') { // Save all attachments /* @var $m IMAPMessage */ $m = $mailBox->getMessage($messageId); diff --git a/lib/Mailbox.php b/lib/Mailbox.php index c213a4f1c..4fad6cc87 100644 --- a/lib/Mailbox.php +++ b/lib/Mailbox.php @@ -295,10 +295,10 @@ class Mailbox implements IMailBox { /** * @param int $messageId - * @param int $attachmentId + * @param string $attachmentId * @return Attachment */ - public function getAttachment(int $messageId, int $attachmentId): Attachment { + public function getAttachment(int $messageId, string $attachmentId): Attachment { return new Attachment($this->conn, $this->mailBox, $messageId, $attachmentId); } diff --git a/lib/Model/IMAPMessage.php b/lib/Model/IMAPMessage.php index 305814d7f..506fe526f 100644 --- a/lib/Model/IMAPMessage.php +++ b/lib/Model/IMAPMessage.php @@ -342,7 +342,7 @@ class IMAPMessage implements IMessage, JsonSerializable { return; } $this->attachments[] = [ - 'id' => (int) $p->getMimeId(), + 'id' => $p->getMimeId(), 'messageId' => $this->messageId, 'fileName' => $filename, 'mime' => $p->getType(), diff --git a/lib/Service/IMailBox.php b/lib/Service/IMailBox.php index 43ad3eb20..012a78958 100644 --- a/lib/Service/IMailBox.php +++ b/lib/Service/IMailBox.php @@ -49,10 +49,10 @@ interface IMailBox { /** * @param int $messageId - * @param int $attachmentId + * @param string $attachmentId * @return Attachment */ - public function getAttachment(int $messageId, int $attachmentId): Attachment; + public function getAttachment(int $messageId, string $attachmentId): Attachment; /** * @param int $messageId diff --git a/tests/Unit/Controller/MessagesControllerTest.php b/tests/Unit/Controller/MessagesControllerTest.php index 669869c20..75c4fc517 100644 --- a/tests/Unit/Controller/MessagesControllerTest.php +++ b/tests/Unit/Controller/MessagesControllerTest.php @@ -247,7 +247,7 @@ class MessagesControllerTest extends TestCase { $accountId = 17; $folderId = base64_encode('my folder'); $messageId = 123; - $attachmentId = 3; + $attachmentId = '2.2'; $targetPath = 'Downloads'; $this->accountService->expects($this->once()) @@ -295,7 +295,7 @@ class MessagesControllerTest extends TestCase { $accountId = 17; $folderId = base64_encode('my folder'); $messageId = 123; - $attachmentId = 3; + $attachmentId = '0'; $targetPath = 'Downloads'; $this->accountService->expects($this->once()) @@ -343,8 +343,13 @@ class MessagesControllerTest extends TestCase { ->will($this->returnValue('abcdefg')); $expected = new JSONResponse(); - $response = $this->controller->saveAttachment($accountId, $folderId, - $messageId, 0, $targetPath); + $response = $this->controller->saveAttachment( + $accountId, + $folderId, + $messageId, + $attachmentId, + $targetPath + ); $this->assertEquals($expected, $response); } |