From 46916ee4f396e71075fd228a87ef294e38825dea Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Thu, 20 Feb 2020 16:12:11 +0100 Subject: Make envelope lists more versatile Signed-off-by: Christoph Wurst --- lib/Controller/MessagesController.php | 40 ++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'lib/Controller/MessagesController.php') diff --git a/lib/Controller/MessagesController.php b/lib/Controller/MessagesController.php index 9a6fc82de..8726c5be7 100755 --- a/lib/Controller/MessagesController.php +++ b/lib/Controller/MessagesController.php @@ -54,6 +54,7 @@ use OCP\IL10N; use OCP\ILogger; use OCP\IRequest; use OCP\IURLGenerator; +use function array_map; use function base64_decode; class MessagesController extends Controller { @@ -176,23 +177,52 @@ class MessagesController extends Controller { return new JSONResponse(null, Http::STATUS_FORBIDDEN); } + $this->logger->debug("loading message of folder <$folderId>"); + + return new JSONResponse( + $this->mailSearch->findMessage( + $account, + base64_decode($folderId), + $id + ) + ); + } + + /** + * @NoAdminRequired + * @TrapError + * + * @param int $accountId + * @param string $folderId + * @param int $messageId + * + * @return JSONResponse + * @throws ServiceException + */ + public function getBody(int $accountId, string $folderId, int $messageId): JSONResponse { + try { + $account = $this->accountService->find($this->currentUserId, $accountId); + } catch (DoesNotExistException $e) { + return new JSONResponse(null, Http::STATUS_FORBIDDEN); + } + $json = $this->mailManager->getMessage( $account, base64_decode($folderId), - $id, + $messageId, true )->getFullMessage( $accountId, base64_decode($folderId), - $id + $messageId ); $json['itineraries'] = $this->itineraryService->extract( $account, base64_decode($folderId), - $id + $messageId ); - $json['attachments'] = array_map(function ($a) use ($accountId, $folderId, $id) { - return $this->enrichDownloadUrl($accountId, $folderId, $id, $a); + $json['attachments'] = array_map(function ($a) use ($accountId, $folderId, $messageId) { + return $this->enrichDownloadUrl($accountId, $folderId, $messageId, $a); }, $json['attachments']); return new JSONResponse($json); -- cgit v1.2.3