diff options
author | Richard Steinmetz <richard@steinmetz.cloud> | 2021-12-17 19:11:27 +0300 |
---|---|---|
committer | Richard Steinmetz <richard@steinmetz.cloud> | 2022-03-28 12:44:36 +0300 |
commit | 6efad68afae361eee60b3850c29680038edb4657 (patch) | |
tree | 887d475301c5d3a8431535aa313a1264dac24560 /lib/Controller/MessagesController.php | |
parent | fdfce08e2a05f401e55cb30776366af6f1870e9f (diff) |
Load itineraries asynchronouslyenh/4823/async-itineraries
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
Diffstat (limited to 'lib/Controller/MessagesController.php')
-rwxr-xr-x | lib/Controller/MessagesController.php | 32 |
1 files changed, 27 insertions, 5 deletions
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 <lukas@owncloud.com> * @author Thomas Imbreckx <zinks@iozero.be> * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Richard Steinmetz <richard@steinmetz.cloud> * * 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(); |