Skip to content

Commit

Permalink
Merge pull request #3949 from nextcloud/fix/stable30-templates
Browse files Browse the repository at this point in the history
fix: Fix missing conflicts on pdf templating
  • Loading branch information
elzody committed Aug 26, 2024
2 parents 672b187 + b0ff210 commit 11a83d2
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/Service/TemplateFieldService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OCP\Files\File;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\Files\Template\Field;
use OCP\Files\Template\FieldType;
use OCP\Http\Client\IClientService;
Expand Down Expand Up @@ -46,12 +47,16 @@ public function extractFields(Node|int $file): array {
}

try {
if (!$file || !$file instanceof File) {
throw new NotFoundException();
}

$localCache = $this->cacheFactory->createLocal('richdocuments_templates/');
$cacheName = $file->getId() . "/" . $file->getEtag();
$cachedResponse = $localCache->get($cacheName);

if ($cachedResponse !== null) {
// return $cachedResponse;
return $cachedResponse;
}

if ($file->getMimeType() === 'application/pdf') {
Expand Down Expand Up @@ -125,6 +130,13 @@ public function fillFields(Node|int $file, array $fields = [], ?string $destinat
$file = $this->rootFolder->getFirstNodeById($file);
}

if (!$file || !$file instanceof File) {
$e = new NotFoundException();
$this->logger->error($e->getMessage());

throw $e;
}

if ($file->getMimeType() === 'application/pdf') {
$content = $this->pdfService->fillFields($file, $fields);
if ($destination !== null) {
Expand Down

0 comments on commit 11a83d2

Please sign in to comment.