mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-04 12:29:43 +00:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
c2d9c73fd4
|
|||
0d6d15fcf7 | |||
f9ad96c78b
|
|||
fcc9529a20
|
4
.changes/v4.5.1.md
Normal file
4
.changes/v4.5.1.md
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
## v4.5.1 - 2025-10-03
|
||||||
|
### Fixed
|
||||||
|
* Add missing javascript dependency
|
||||||
|
* Add exception handling for conversion of attachment on sending external, when documens are already in pdf
|
@@ -6,6 +6,11 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
|
|||||||
and is generated by [Changie](https://github.com/miniscruff/changie).
|
and is generated by [Changie](https://github.com/miniscruff/changie).
|
||||||
|
|
||||||
|
|
||||||
|
## v4.5.1 - 2025-10-03
|
||||||
|
### Fixed
|
||||||
|
* Add missing javascript dependency
|
||||||
|
* Add exception handling for conversion of attachment on sending external, when documens are already in pdf
|
||||||
|
|
||||||
## v4.5.0 - 2025-10-03
|
## v4.5.0 - 2025-10-03
|
||||||
### Feature
|
### Feature
|
||||||
* Only allow delete of attachment on workflows that are not final
|
* Only allow delete of attachment on workflows that are not final
|
||||||
|
@@ -55,6 +55,7 @@
|
|||||||
"@tsconfig/node20": "^20.1.4",
|
"@tsconfig/node20": "^20.1.4",
|
||||||
"@types/dompurify": "^3.0.5",
|
"@types/dompurify": "^3.0.5",
|
||||||
"@types/leaflet": "^1.9.3",
|
"@types/leaflet": "^1.9.3",
|
||||||
|
"@vueuse/core": "^13.9.0",
|
||||||
"bootstrap-icons": "^1.11.3",
|
"bootstrap-icons": "^1.11.3",
|
||||||
"dropzone": "^5.7.6",
|
"dropzone": "^5.7.6",
|
||||||
"es6-promise": "^4.2.8",
|
"es6-promise": "^4.2.8",
|
||||||
|
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\DocStoreBundle\Exception;
|
||||||
|
|
||||||
|
class ConversionWithSameMimeTypeException extends \RuntimeException
|
||||||
|
{
|
||||||
|
public function __construct(string $mimeType, ?\Throwable $previous = null)
|
||||||
|
{
|
||||||
|
parent::__construct("Conversion to same MIME type '{$mimeType}' is not allowed: already at the same MIME type", 0, $previous);
|
||||||
|
}
|
||||||
|
}
|
@@ -15,6 +15,7 @@ use Chill\DocStoreBundle\Entity\StoredObject;
|
|||||||
use Chill\DocStoreBundle\Entity\StoredObjectPointInTime;
|
use Chill\DocStoreBundle\Entity\StoredObjectPointInTime;
|
||||||
use Chill\DocStoreBundle\Entity\StoredObjectPointInTimeReasonEnum;
|
use Chill\DocStoreBundle\Entity\StoredObjectPointInTimeReasonEnum;
|
||||||
use Chill\DocStoreBundle\Entity\StoredObjectVersion;
|
use Chill\DocStoreBundle\Entity\StoredObjectVersion;
|
||||||
|
use Chill\DocStoreBundle\Exception\ConversionWithSameMimeTypeException;
|
||||||
use Chill\DocStoreBundle\Exception\StoredObjectManagerException;
|
use Chill\DocStoreBundle\Exception\StoredObjectManagerException;
|
||||||
use Chill\WopiBundle\Service\WopiConverter;
|
use Chill\WopiBundle\Service\WopiConverter;
|
||||||
use Symfony\Component\Mime\MimeTypesInterface;
|
use Symfony\Component\Mime\MimeTypesInterface;
|
||||||
@@ -44,6 +45,7 @@ class StoredObjectToPdfConverter
|
|||||||
* @throws \UnexpectedValueException if the preferred mime type for the conversion is not found
|
* @throws \UnexpectedValueException if the preferred mime type for the conversion is not found
|
||||||
* @throws \RuntimeException if the conversion or storage of the new version fails
|
* @throws \RuntimeException if the conversion or storage of the new version fails
|
||||||
* @throws StoredObjectManagerException
|
* @throws StoredObjectManagerException
|
||||||
|
* @throws ConversionWithSameMimeTypeException if the document has already the same mime type79*
|
||||||
*/
|
*/
|
||||||
public function addConvertedVersion(StoredObject $storedObject, string $lang, $convertTo = 'pdf', bool $includeConvertedContent = false): array
|
public function addConvertedVersion(StoredObject $storedObject, string $lang, $convertTo = 'pdf', bool $includeConvertedContent = false): array
|
||||||
{
|
{
|
||||||
@@ -56,7 +58,7 @@ class StoredObjectToPdfConverter
|
|||||||
$currentVersion = $storedObject->getCurrentVersion();
|
$currentVersion = $storedObject->getCurrentVersion();
|
||||||
|
|
||||||
if ($currentVersion->getType() === $newMimeType) {
|
if ($currentVersion->getType() === $newMimeType) {
|
||||||
throw new \UnexpectedValueException('Already at the same mime type');
|
throw new ConversionWithSameMimeTypeException($newMimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = $this->storedObjectManager->read($currentVersion);
|
$content = $this->storedObjectManager->read($currentVersion);
|
||||||
|
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\MainBundle\Workflow\Messenger;
|
namespace Chill\MainBundle\Workflow\Messenger;
|
||||||
|
|
||||||
|
use Chill\DocStoreBundle\Exception\ConversionWithSameMimeTypeException;
|
||||||
use Chill\DocStoreBundle\Exception\StoredObjectManagerException;
|
use Chill\DocStoreBundle\Exception\StoredObjectManagerException;
|
||||||
use Chill\DocStoreBundle\Service\StoredObjectToPdfConverter;
|
use Chill\DocStoreBundle\Service\StoredObjectToPdfConverter;
|
||||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
||||||
@@ -55,6 +56,8 @@ final readonly class PostSendExternalMessageHandler implements MessageHandlerInt
|
|||||||
$this->storedObjectToPdfConverter->addConvertedVersion($attachment->getProxyStoredObject(), $locale);
|
$this->storedObjectToPdfConverter->addConvertedVersion($attachment->getProxyStoredObject(), $locale);
|
||||||
} catch (StoredObjectManagerException $e) {
|
} catch (StoredObjectManagerException $e) {
|
||||||
$this->logger->error('Error converting attachment to PDF', ['backtrace' => $e->getTraceAsString(), 'attachment_id' => $attachment->getId()]);
|
$this->logger->error('Error converting attachment to PDF', ['backtrace' => $e->getTraceAsString(), 'attachment_id' => $attachment->getId()]);
|
||||||
|
} catch (ConversionWithSameMimeTypeException $e) {
|
||||||
|
$this->logger->error('Error converting attachment to PDF: already at the same MIME type', ['backtrace' => $e->getTraceAsString(), 'attachment_id' => $attachment->getId()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +68,8 @@ final readonly class PostSendExternalMessageHandler implements MessageHandlerInt
|
|||||||
$this->storedObjectToPdfConverter->addConvertedVersion($storedObject, $locale);
|
$this->storedObjectToPdfConverter->addConvertedVersion($storedObject, $locale);
|
||||||
} catch (StoredObjectManagerException $e) {
|
} catch (StoredObjectManagerException $e) {
|
||||||
$this->logger->error('Error converting stored object to PDF', ['backtrace' => $e->getTraceAsString(), 'stored_object_id' => $storedObject->getId(), 'workflow_id' => $entityWorkflow->getId()]);
|
$this->logger->error('Error converting stored object to PDF', ['backtrace' => $e->getTraceAsString(), 'stored_object_id' => $storedObject->getId(), 'workflow_id' => $entityWorkflow->getId()]);
|
||||||
|
} catch (ConversionWithSameMimeTypeException $e) {
|
||||||
|
$this->logger->error('Error converting stored object to PDF: already at the same MIME type', ['backtrace' => $e->getTraceAsString(), 'stored_object_id' => $storedObject->getId(), 'workflow_id' => $entityWorkflow->getId()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user