Skip to content

Commit

Permalink
Combine itineraries and schema calls in getBody call
Browse files Browse the repository at this point in the history
  • Loading branch information
gfaudriga committed Apr 9, 2024
1 parent 09e74f8 commit 97dbdc0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
6 changes: 3 additions & 3 deletions lib/Controller/MessagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Check failure on line 253 in lib/Controller/MessagesController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

RedundantCondition

lib/Controller/MessagesController.php:253:8: RedundantCondition: Operand of type Nextcloud\KItinerary\Itinerary is always truthy (see https://psalm.dev/122)

Check failure on line 253 in lib/Controller/MessagesController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable26

RedundantCondition

lib/Controller/MessagesController.php:253:8: RedundantCondition: Operand of type Nextcloud\KItinerary\Itinerary is always truthy (see https://psalm.dev/122)

Check failure on line 253 in lib/Controller/MessagesController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable28

RedundantCondition

lib/Controller/MessagesController.php:253:8: RedundantCondition: Operand of type Nextcloud\KItinerary\Itinerary is always truthy (see https://psalm.dev/122)

Check failure on line 253 in lib/Controller/MessagesController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable27

RedundantCondition

lib/Controller/MessagesController.php:253:8: RedundantCondition: Operand of type Nextcloud\KItinerary\Itinerary is always truthy (see https://psalm.dev/122)
$json['itineraries'] = $itineraries;
$json['schema'] = $itineraries;
}
} else {
$schema = $this->schemaService->extract($account, $mailbox, $message->getUid());
if ($schema) {
$json["schema"] = $schema;
$json['schema'] = $schema;
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/Service/SchemaService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
15 changes: 0 additions & 15 deletions src/components/ThreadEnvelope.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 97dbdc0

Please sign in to comment.