From 6efad68afae361eee60b3850c29680038edb4657 Mon Sep 17 00:00:00 2001 From: Richard Steinmetz Date: Fri, 17 Dec 2021 17:11:27 +0100 Subject: Load itineraries asynchronously Signed-off-by: Richard Steinmetz --- lib/Controller/MessagesController.php | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'lib/Controller/MessagesController.php') diff --git a/lib/Controller/MessagesController.php b/lib/Controller/MessagesController.php index e3cc7a3e7..f2f083d38 100755 --- a/lib/Controller/MessagesController.php +++ b/lib/Controller/MessagesController.php @@ -11,6 +11,7 @@ declare(strict_types=1); * @author Lukas Reschke * @author Thomas Imbreckx * @author Thomas Müller + * @author Richard Steinmetz * * Mail * @@ -248,11 +249,10 @@ class MessagesController extends Controller { $message->getUid(), true )->getFullMessage($id); - $json['itineraries'] = $this->itineraryService->extract( - $account, - $mailbox->getName(), - $message->getUid() - ); + $itineraries = $this->itineraryService->getCached($account, $mailbox, $message->getUid()); + if ($itineraries) { + $json['itineraries'] = $itineraries; + } $json['attachments'] = array_map(function ($a) use ($id) { return $this->enrichDownloadUrl( $id, @@ -272,6 +272,28 @@ class MessagesController extends Controller { return $response; } + /** + * @NoAdminRequired + * @TrapError + * + * @param int $id + * + * @return JSONResponse + * + * @throws ClientException + */ + public function getItineraries(int $id): JSONResponse { + 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); + } + + return new JsonResponse($this->itineraryService->extract($account, $mailbox, $message->getUid())); + } + private function isSenderTrusted(Message $message): bool { $from = $message->getFrom(); $first = $from->first(); -- cgit v1.2.3