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:
authorRichard Steinmetz <richard@steinmetz.cloud>2022-08-02 16:35:15 +0300
committerRichard Steinmetz <richard@steinmetz.cloud>2022-08-09 12:56:30 +0300
commit23399752fb7db380cf9462e965d1d0ce14d956e8 (patch)
tree0d0c7976cd1528dc5fa28373ac23a1304fd7f0d1 /lib/Controller/MessagesController.php
parente2857d0b64e09d7c16333046eda2f555eed52c4f (diff)
Add envelope action links to download whole message
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
Diffstat (limited to 'lib/Controller/MessagesController.php')
-rwxr-xr-xlib/Controller/MessagesController.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/Controller/MessagesController.php b/lib/Controller/MessagesController.php
index 36945b46c..68ecfe2c7 100755
--- a/lib/Controller/MessagesController.php
+++ b/lib/Controller/MessagesController.php
@@ -438,6 +438,39 @@ class MessagesController extends Controller {
}
/**
+ * Export a whole message as an .eml file.
+ *
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @TrapError
+ *
+ * @param int $id
+ * @return Response
+ * @throws ClientException
+ * @throws ServiceException
+ */
+ public function export(int $id): Response {
+ try {
+ $message = $this->mailManager->getMessage($this->currentUserId, $id);
+ $mailbox = $this->mailManager->getMailbox($this->currentUserId, $message->getMailboxId());
+ $account = $this->accountService->find($this->currentUserId, $mailbox->getAccountId());
+ } catch (DoesNotExistException $e) {
+ return new JSONResponse([], Http::STATUS_FORBIDDEN);
+ }
+
+ $source = $this->mailManager->getSource(
+ $account,
+ $mailbox->getName(),
+ $message->getUid()
+ );
+ return new AttachmentDownloadResponse(
+ $source,
+ $message->getSubject() . '.eml',
+ 'message/rfc822',
+ );
+ }
+
+ /**
* @NoAdminRequired
* @NoCSRFRequired
* @TrapError