Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/Conversion/ConversionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
namespace OCA\Richdocuments\Conversion;

use OCA\Richdocuments\Service\RemoteService;
use OCA\Richdocuments\Service\SecureViewService;
use OCP\Files\Conversion\ConversionMimeProvider;
use OCP\Files\Conversion\IConversionProvider;
use OCP\Files\File;
use OCP\Files\NotFoundException;
use OCP\IL10N;
use OCP\L10N\IFactory;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -53,6 +55,7 @@ public function __construct(
private RemoteService $remoteService,
private LoggerInterface $logger,
IFactory $l10nFactory,
private SecureViewService $secureViewService,
) {
$this->l10n = $l10nFactory->get('richdocuments');
}
Expand Down Expand Up @@ -144,6 +147,24 @@ public function convertFile(File $file, string $targetMimeType): mixed {
));
}

if ($this->secureViewService->isEnabled()) {
try {
$secured = $this->secureViewService->shouldSecure(
$file->getInternalPath(),
$file->getStorage(),
Comment thread
chrip marked this conversation as resolved.
false,
);
} catch (NotFoundException $e) {
$this->logger->warning('Could not determine Secure View status for conversion target', ['exception' => $e]);
throw new \Exception($this->l10n->t('Conversion is unavailable for this file.'));
}
if ($secured) {
throw new \Exception($this->l10n->t(
'Conversion is blocked because the file is protected by Secure View.'
));
}
}

return $this->remoteService->convertFileTo($file, $targetFileExtension);
}

Expand Down
Loading