From 97dbdc05e26334f09d075efd8a4e646cd7896f07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerke=20Fr=C3=B6lje?= Date: Tue, 9 Apr 2024 14:57:58 +0200 Subject: [PATCH] Combine itineraries and schema calls in getBody call --- lib/Controller/MessagesController.php | 6 +++--- lib/Service/SchemaService.php | 1 + src/components/ThreadEnvelope.vue | 15 --------------- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/lib/Controller/MessagesController.php b/lib/Controller/MessagesController.php index 6c152d042e..2e6c07e0c9 100755 --- a/lib/Controller/MessagesController.php +++ b/lib/Controller/MessagesController.php @@ -249,14 +249,14 @@ public function getBody(int $id): JSONResponse { $extractionLibrary = $this->config->getAppValue('mail', 'markup_library_used_for_extraction', 'h2ld'); if ($extractionLibrary === 'kitinerary') { - $itineraries = $this->itineraryService->getCached($account, $mailbox, $message->getUid()); + $itineraries = $this->itineraryService->extract($account, $mailbox, $message->getUid()); if ($itineraries) { - $json['itineraries'] = $itineraries; + $json['schema'] = $itineraries; } } else { $schema = $this->schemaService->extract($account, $mailbox, $message->getUid()); if ($schema) { - $json["schema"] = $schema; + $json['schema'] = $schema; } } diff --git a/lib/Service/SchemaService.php b/lib/Service/SchemaService.php index 997d9db3f6..c441d9abfb 100644 --- a/lib/Service/SchemaService.php +++ b/lib/Service/SchemaService.php @@ -71,6 +71,7 @@ private function buildCacheKey(Account $account, Mailbox $mailbox, int $id): str public function getCached(Account $account, Mailbox $mailbox, int $id) { if ($cached = ($this->cache->get($this->buildCacheKey($account, $mailbox, $id)))) { + $this->logger->debug('Loading schema entries from cache'); return json_decode($cached); } diff --git a/src/components/ThreadEnvelope.vue b/src/components/ThreadEnvelope.vue index 420c511b0f..f0093679f2 100644 --- a/src/components/ThreadEnvelope.vue +++ b/src/components/ThreadEnvelope.vue @@ -614,21 +614,6 @@ export default { this.smartReplies = await smartReply(this.envelope.databaseId) } }, - async fetchItineraries() { - // Sanity check before actually making the request - if (!this.message.hasHtmlBody && this.message.attachments.length === 0) { - return - } - - logger.debug(`Fetching itineraries for message ${this.envelope.databaseId}`) - - try { - const itineraries = await this.$store.dispatch('fetchItineraries', this.envelope.databaseId) - logger.debug(`Itineraries of message ${this.envelope.databaseId} fetched`, { itineraries }) - } catch (error) { - logger.error(`Could not fetch itineraries of message ${this.envelope.databaseId}`, { error }) - } - }, async fetchDkim() { if (this.message.hasDkimSignature === false) { return