Merge branch 'main' of ssh://git.homelab.nestor-server.fr:2222/colgora/Mangarr
All checks were successful
Build and Deploy / deploy (push) Successful in 1m46s
All checks were successful
Build and Deploy / deploy (push) Successful in 1m46s
# Conflicts: # src/Domain/Manga/Application/CommandHandler/DeleteChapterHandler.php # src/Domain/Manga/Application/CommandHandler/EditMultipleChaptersHandler.php # src/Domain/Manga/Application/EventListener/ChapterImportedEventListener.php # src/Domain/Manga/Application/EventListener/VolumeImportedEventListener.php # src/Domain/Manga/Application/Response/ChapterResponse.php # src/Domain/Manga/Infrastructure/ApiPlatform/State/Provider/DeleteCbzProvider.php # src/Domain/Manga/Infrastructure/ApiPlatform/State/Provider/DeleteChapterProvider.php # src/Domain/Manga/Infrastructure/Persistence/Repository/LegacyChapterRepository.php
This commit is contained in:
@@ -3,19 +3,17 @@
|
||||
namespace App\Domain\Manga\Application\CommandHandler;
|
||||
|
||||
use App\Domain\Manga\Application\Command\DeleteCbz;
|
||||
use App\Domain\Manga\Domain\Contract\Repository\ChapterRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Contract\Service\FileServiceInterface;
|
||||
use App\Domain\Manga\Domain\Exception\ChapterNotFoundException;
|
||||
use App\Domain\Manga\Domain\Exception\CbzFileNotFoundException;
|
||||
use App\Domain\Manga\Domain\Model\Chapter;
|
||||
use App\Domain\Manga\Domain\Model\ValueObject\ChapterId;
|
||||
use App\Domain\Shared\Domain\Contract\CommandHandlerInterface;
|
||||
use App\Domain\Shared\Domain\Contract\CommandInterface;
|
||||
|
||||
readonly class DeleteCbzHandler implements CommandHandlerInterface
|
||||
{
|
||||
public function __construct(
|
||||
private ChapterRepositoryInterface $chapterRepository,
|
||||
private MangaRepositoryInterface $mangaRepository,
|
||||
private FileServiceInterface $fileService
|
||||
) {
|
||||
}
|
||||
@@ -24,33 +22,18 @@ readonly class DeleteCbzHandler implements CommandHandlerInterface
|
||||
{
|
||||
assert($command instanceof DeleteCbz);
|
||||
|
||||
$chapter = $this->chapterRepository->findVisibleById($command->chapterId);
|
||||
$chapter = $this->mangaRepository->findVisibleChapterById($command->chapterId);
|
||||
|
||||
if (!$chapter) {
|
||||
throw new ChapterNotFoundException($command->chapterId);
|
||||
}
|
||||
|
||||
// Check if chapter has a CBZ file
|
||||
if (!$chapter->isAvailable()) {
|
||||
throw new CbzFileNotFoundException($command->chapterId);
|
||||
}
|
||||
|
||||
// Delete the physical CBZ file
|
||||
// Note: We'll need to get the CBZ path from somewhere, likely from a legacy repository
|
||||
// For now, we'll just mark the chapter as not available
|
||||
|
||||
// Update chapter to mark CBZ as not available
|
||||
$updatedChapter = new Chapter(
|
||||
new ChapterId($chapter->getId()),
|
||||
$chapter->getMangaId(),
|
||||
$chapter->getNumber(),
|
||||
$chapter->getTitle(),
|
||||
$chapter->getVolume(),
|
||||
$chapter->isVisible(),
|
||||
null,
|
||||
$chapter->getCreatedAt()
|
||||
);
|
||||
|
||||
$this->chapterRepository->save($updatedChapter);
|
||||
$manga = $this->mangaRepository->findById($chapter->getMangaId()->getValue());
|
||||
$manga->removeChapterPages($chapter);
|
||||
$this->mangaRepository->save($manga);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,15 @@
|
||||
namespace App\Domain\Manga\Application\CommandHandler;
|
||||
|
||||
use App\Domain\Manga\Application\Command\DeleteChapter;
|
||||
use App\Domain\Manga\Domain\Contract\Repository\ChapterRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Exception\ChapterNotFoundException;
|
||||
use App\Domain\Manga\Domain\Model\Chapter;
|
||||
use App\Domain\Manga\Domain\Model\ValueObject\ChapterId;
|
||||
use App\Domain\Shared\Domain\Contract\CommandHandlerInterface;
|
||||
use App\Domain\Shared\Domain\Contract\CommandInterface;
|
||||
|
||||
readonly class DeleteChapterHandler implements CommandHandlerInterface
|
||||
{
|
||||
public function __construct(
|
||||
private ChapterRepositoryInterface $chapterRepository
|
||||
private MangaRepositoryInterface $mangaRepository
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -21,23 +19,14 @@ readonly class DeleteChapterHandler implements CommandHandlerInterface
|
||||
{
|
||||
assert($command instanceof DeleteChapter);
|
||||
|
||||
$chapter = $this->chapterRepository->findVisibleById($command->chapterId);
|
||||
$chapter = $this->mangaRepository->findVisibleChapterById($command->chapterId);
|
||||
|
||||
if (!$chapter) {
|
||||
throw new ChapterNotFoundException($command->chapterId);
|
||||
}
|
||||
|
||||
$updatedChapter = new Chapter(
|
||||
id: new ChapterId($chapter->getId()),
|
||||
mangaId: $chapter->getMangaId(),
|
||||
number: $chapter->getNumber(),
|
||||
title: $chapter->getTitle(),
|
||||
volume: $chapter->getVolume(),
|
||||
isVisible: false,
|
||||
cbzPath: $chapter->getCbzPath(),
|
||||
createdAt: $chapter->getCreatedAt()
|
||||
);
|
||||
|
||||
$this->chapterRepository->save($updatedChapter);
|
||||
$manga = $this->mangaRepository->findById($chapter->getMangaId()->getValue());
|
||||
$manga->hideChapter($chapter);
|
||||
$this->mangaRepository->save($manga);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,36 +3,36 @@
|
||||
namespace App\Domain\Manga\Application\CommandHandler;
|
||||
|
||||
use App\Domain\Manga\Application\Command\EditMultipleChapters;
|
||||
use App\Domain\Manga\Domain\Contract\Repository\ChapterRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Exception\ChapterNotFoundException;
|
||||
|
||||
readonly class EditMultipleChaptersHandler
|
||||
{
|
||||
public function __construct(
|
||||
private ChapterRepositoryInterface $chapterRepository
|
||||
private MangaRepositoryInterface $mangaRepository
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(EditMultipleChapters $command): void
|
||||
{
|
||||
foreach ($command->chapters as $chapterData) {
|
||||
$chapter = $this->chapterRepository->findById($chapterData->id);
|
||||
$chapter = $this->mangaRepository->findChapterById($chapterData->id);
|
||||
|
||||
if (!$chapter) {
|
||||
throw new ChapterNotFoundException($chapterData->id);
|
||||
}
|
||||
|
||||
$updatedChapter = $chapter;
|
||||
$manga = $this->mangaRepository->findById($chapter->getMangaId()->getValue());
|
||||
|
||||
if ($chapterData->title !== null) {
|
||||
$updatedChapter = $updatedChapter->updateTitle($chapterData->title);
|
||||
$manga->updateChapterTitle($chapter, $chapterData->title);
|
||||
}
|
||||
|
||||
if ($chapterData->volume !== null) {
|
||||
$updatedChapter = $updatedChapter->updateVolume($chapterData->volume);
|
||||
$manga->updateChapterVolume($chapter, $chapterData->volume);
|
||||
}
|
||||
|
||||
$this->chapterRepository->save($updatedChapter);
|
||||
$this->mangaRepository->save($manga);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,6 @@ readonly class FetchMangaChaptersHandler
|
||||
|
||||
// Synchronisation initiale (pas d'événements)
|
||||
$this->chapterSynchronizationService->synchronizeChapters($manga);
|
||||
$this->mangaRepository->save($manga);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,20 +3,15 @@
|
||||
namespace App\Domain\Manga\Application\CommandHandler;
|
||||
|
||||
use App\Domain\Manga\Application\Command\ImportChapter;
|
||||
use App\Domain\Manga\Domain\Contract\Repository\ChapterRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Exception\MangaNotFoundException;
|
||||
use App\Domain\Manga\Domain\Exception\ChapterNotFoundException;
|
||||
use App\Domain\Manga\Domain\Model\Chapter;
|
||||
use App\Domain\Manga\Domain\Model\ValueObject\ChapterId;
|
||||
use App\Domain\Shared\Domain\Contract\MangaPathManagerInterface;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
readonly class ImportChapterHandler
|
||||
{
|
||||
public function __construct(
|
||||
private MangaRepositoryInterface $mangaRepository,
|
||||
private ChapterRepositoryInterface $chapterRepository,
|
||||
private MangaPathManagerInterface $pathManager
|
||||
) {
|
||||
}
|
||||
@@ -35,7 +30,7 @@ readonly class ImportChapterHandler
|
||||
}
|
||||
|
||||
// 3. Check if chapter exists
|
||||
$existingChapter = $this->chapterRepository->findByMangaIdAndChapterNumber(
|
||||
$existingChapter = $this->mangaRepository->findChapterByMangaIdAndNumber(
|
||||
$command->mangaId,
|
||||
$command->chapterNumber
|
||||
);
|
||||
@@ -47,37 +42,20 @@ readonly class ImportChapterHandler
|
||||
// 4. Save the CBZ file to storage using the path manager
|
||||
$cbzPath = $this->saveCbzFile($command, $manga, $existingChapter);
|
||||
|
||||
// 5. Update existing chapter with new CBZ path
|
||||
$updatedChapter = new Chapter(
|
||||
id: new ChapterId($existingChapter->getId()),
|
||||
mangaId: $existingChapter->getMangaId(),
|
||||
number: $existingChapter->getNumber(),
|
||||
title: $existingChapter->getTitle(),
|
||||
volume: $existingChapter->getVolume(),
|
||||
isVisible: $existingChapter->isVisible(),
|
||||
cbzPath: $cbzPath,
|
||||
createdAt: $existingChapter->getCreatedAt()
|
||||
);
|
||||
$this->chapterRepository->save($updatedChapter);
|
||||
// 5. Update existing chapter with new path through the aggregate
|
||||
$manga->updateChapterPages($existingChapter, $cbzPath, $existingChapter->getPageCount());
|
||||
$this->mangaRepository->save($manga);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that the binary data is a valid CBZ (ZIP) file
|
||||
*/
|
||||
private function isValidCbzFile(string $fileBinary): bool
|
||||
{
|
||||
// CBZ files are ZIP archives, check for ZIP magic number
|
||||
$zipMagicNumber = "\x50\x4b\x03\x04"; // PK\x03\x04
|
||||
|
||||
return strpos($fileBinary, $zipMagicNumber) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the CBZ file to storage and return the path
|
||||
*/
|
||||
private function saveCbzFile(ImportChapter $command, \App\Domain\Manga\Domain\Model\Manga $manga, Chapter $chapter): string
|
||||
private function saveCbzFile(ImportChapter $command, \App\Domain\Manga\Domain\Model\Manga $manga, \App\Domain\Manga\Domain\Model\Chapter $chapter): string
|
||||
{
|
||||
// Build the final CBZ path using the path manager (creates directories)
|
||||
$volumeNumber = $chapter->getVolume() ?? 0;
|
||||
$cbzPath = $this->pathManager->buildChapterCbzPath(
|
||||
$manga->getTitle()->getValue(),
|
||||
@@ -86,7 +64,6 @@ readonly class ImportChapterHandler
|
||||
(string)$command->chapterNumber
|
||||
);
|
||||
|
||||
// Write the binary content directly to the CBZ path
|
||||
if (!file_put_contents($cbzPath, $command->fileBinary)) {
|
||||
throw new \RuntimeException('Failed to save CBZ file');
|
||||
}
|
||||
|
||||
@@ -3,18 +3,14 @@
|
||||
namespace App\Domain\Manga\Application\CommandHandler;
|
||||
|
||||
use App\Domain\Manga\Application\Command\ImportVolume;
|
||||
use App\Domain\Manga\Domain\Contract\Repository\ChapterRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Exception\MangaNotFoundException;
|
||||
use App\Domain\Manga\Domain\Model\Chapter;
|
||||
use App\Domain\Manga\Domain\Model\ValueObject\ChapterId;
|
||||
use App\Domain\Shared\Domain\Contract\MangaPathManagerInterface;
|
||||
|
||||
readonly class ImportVolumeHandler
|
||||
{
|
||||
public function __construct(
|
||||
private MangaRepositoryInterface $mangaRepository,
|
||||
private ChapterRepositoryInterface $chapterRepository,
|
||||
private MangaPathManagerInterface $pathManager
|
||||
) {
|
||||
}
|
||||
@@ -33,7 +29,7 @@ readonly class ImportVolumeHandler
|
||||
}
|
||||
|
||||
// 3. Get all chapters for this volume
|
||||
$chapters = $this->chapterRepository->findByMangaIdAndVolume(
|
||||
$chapters = $this->mangaRepository->findChaptersByMangaIdAndVolume(
|
||||
$command->mangaId,
|
||||
$command->volumeNumber
|
||||
);
|
||||
@@ -47,46 +43,28 @@ readonly class ImportVolumeHandler
|
||||
// 4. Save the CBZ file to storage using the path manager
|
||||
$cbzPath = $this->saveCbzFile($command, $manga);
|
||||
|
||||
// 5. Update all chapters with the volume CBZ path
|
||||
// 5. Update all chapters with the volume path through the aggregate
|
||||
foreach ($chapters as $chapter) {
|
||||
$updatedChapter = new Chapter(
|
||||
id: new ChapterId($chapter->getId()),
|
||||
mangaId: $chapter->getMangaId(),
|
||||
number: $chapter->getNumber(),
|
||||
title: $chapter->getTitle(),
|
||||
volume: $chapter->getVolume(),
|
||||
isVisible: $chapter->isVisible(),
|
||||
cbzPath: $cbzPath,
|
||||
createdAt: $chapter->getCreatedAt()
|
||||
);
|
||||
$this->chapterRepository->save($updatedChapter);
|
||||
$manga->updateChapterPages($chapter, $cbzPath, $chapter->getPageCount());
|
||||
}
|
||||
$this->mangaRepository->save($manga);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that the binary data is a valid CBZ (ZIP) file
|
||||
*/
|
||||
private function isValidCbzFile(string $fileBinary): bool
|
||||
{
|
||||
// CBZ files are ZIP archives, check for ZIP magic number
|
||||
$zipMagicNumber = "\x50\x4b\x03\x04"; // PK\x03\x04
|
||||
|
||||
return strpos($fileBinary, $zipMagicNumber) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the CBZ file to storage and return the path
|
||||
*/
|
||||
private function saveCbzFile(ImportVolume $command, \App\Domain\Manga\Domain\Model\Manga $manga): string
|
||||
{
|
||||
// Build the final CBZ path using the path manager (creates directories)
|
||||
$cbzPath = $this->pathManager->buildVolumeCbzPath(
|
||||
$manga->getTitle()->getValue(),
|
||||
(string)$manga->getPublicationYear(),
|
||||
$command->volumeNumber
|
||||
);
|
||||
|
||||
// Write the binary content directly to the CBZ path
|
||||
if (!file_put_contents($cbzPath, $command->fileBinary)) {
|
||||
throw new \RuntimeException('Failed to save CBZ file');
|
||||
}
|
||||
|
||||
@@ -4,10 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Domain\Manga\Application\EventListener;
|
||||
|
||||
use App\Domain\Manga\Domain\Contract\Repository\ChapterRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Model\Chapter;
|
||||
use App\Domain\Manga\Domain\Model\ValueObject\ChapterId;
|
||||
use App\Domain\Manga\Domain\Model\ValueObject\MangaSlug;
|
||||
use App\Domain\Shared\Domain\Event\ChapterImported;
|
||||
|
||||
@@ -15,7 +12,6 @@ readonly class ChapterImportedEventListener
|
||||
{
|
||||
public function __construct(
|
||||
private MangaRepositoryInterface $mangaRepository,
|
||||
private ChapterRepositoryInterface $chapterRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -23,23 +19,14 @@ readonly class ChapterImportedEventListener
|
||||
{
|
||||
$manga = $this->mangaRepository->findBySlug(new MangaSlug($event->mangaSlug));
|
||||
if (!$manga) {
|
||||
return; // Manga introuvable, on ignore
|
||||
return;
|
||||
}
|
||||
|
||||
$chapters = $this->chapterRepository->findVisibleByMangaIdAndVolume($manga->getId()->getValue(), (int) $event->volume);
|
||||
$chapters = $this->mangaRepository->findVisibleChaptersByMangaIdAndVolume($manga->getId()->getValue(), (int) $event->volume);
|
||||
foreach ($chapters as $chapter) {
|
||||
if ($chapter->getNumber() === (float) $event->chapterNumber) {
|
||||
$updated = new Chapter(
|
||||
new ChapterId($chapter->getId()),
|
||||
$chapter->getMangaId(),
|
||||
$chapter->getNumber(),
|
||||
$chapter->getTitle(),
|
||||
$chapter->getVolume(),
|
||||
$chapter->isVisible(),
|
||||
$event->cbzPath,
|
||||
$chapter->getCreatedAt(),
|
||||
);
|
||||
$this->chapterRepository->save($updated);
|
||||
$manga->updateChapterPages($chapter, $event->cbzPath, $chapter->getPageCount());
|
||||
$this->mangaRepository->save($manga);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Domain\Manga\Application\EventListener;
|
||||
|
||||
use App\Domain\Manga\Domain\Contract\Repository\ChapterRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Model\Chapter;
|
||||
use App\Domain\Manga\Domain\Model\ValueObject\ChapterId;
|
||||
use App\Domain\Manga\Domain\Model\ValueObject\MangaSlug;
|
||||
use App\Domain\Shared\Domain\Event\VolumeImported;
|
||||
|
||||
@@ -15,7 +12,6 @@ readonly class VolumeImportedEventListener
|
||||
{
|
||||
public function __construct(
|
||||
private MangaRepositoryInterface $mangaRepository,
|
||||
private ChapterRepositoryInterface $chapterRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -26,23 +22,14 @@ readonly class VolumeImportedEventListener
|
||||
return;
|
||||
}
|
||||
|
||||
$chapters = $this->chapterRepository->findByMangaIdAndVolume($manga->getId()->getValue(), (int) $event->volume);
|
||||
$chapters = $this->mangaRepository->findChaptersByMangaIdAndVolume($manga->getId()->getValue(), (int) $event->volume);
|
||||
if ($chapters === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($chapters as $chapter) {
|
||||
$updated = new Chapter(
|
||||
new ChapterId($chapter->getId()),
|
||||
$chapter->getMangaId(),
|
||||
$chapter->getNumber(),
|
||||
$chapter->getTitle(),
|
||||
$chapter->getVolume(),
|
||||
$chapter->isVisible(),
|
||||
$event->cbzPath,
|
||||
$chapter->getCreatedAt(),
|
||||
);
|
||||
$this->chapterRepository->save($updated);
|
||||
$manga->updateChapterPages($chapter, $event->cbzPath, $chapter->getPageCount());
|
||||
}
|
||||
$this->mangaRepository->save($manga);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace App\Domain\Manga\Application\QueryHandler;
|
||||
|
||||
use App\Domain\Manga\Application\Query\DownloadCbz;
|
||||
use App\Domain\Manga\Application\Response\DownloadResponse;
|
||||
use App\Domain\Manga\Domain\Contract\Repository\ChapterRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Contract\Service\FileServiceInterface;
|
||||
use App\Domain\Manga\Domain\Exception\CbzFileNotFoundException;
|
||||
use App\Domain\Manga\Domain\Exception\ChapterNotFoundException;
|
||||
@@ -16,7 +16,7 @@ use App\Domain\Shared\Domain\Contract\ResponseInterface;
|
||||
readonly class DownloadCbzHandler implements QueryHandlerInterface
|
||||
{
|
||||
public function __construct(
|
||||
private ChapterRepositoryInterface $chapterRepository,
|
||||
private MangaRepositoryInterface $mangaRepository,
|
||||
private FileServiceInterface $fileService
|
||||
) {
|
||||
}
|
||||
@@ -25,7 +25,7 @@ readonly class DownloadCbzHandler implements QueryHandlerInterface
|
||||
{
|
||||
assert($query instanceof DownloadCbz);
|
||||
|
||||
$chapter = $this->chapterRepository->findVisibleById($query->chapterId);
|
||||
$chapter = $this->mangaRepository->findVisibleChapterById($query->chapterId);
|
||||
|
||||
if (!$chapter) {
|
||||
throw new ChapterNotFoundException($query->chapterId);
|
||||
@@ -35,14 +35,11 @@ readonly class DownloadCbzHandler implements QueryHandlerInterface
|
||||
throw new ChapterNotAvailableException($query->chapterId);
|
||||
}
|
||||
|
||||
// Use the actual CBZ path from the chapter
|
||||
$cbzPath = $chapter->getCbzPath();
|
||||
|
||||
// Extract the existing filename from the path
|
||||
$filename = basename($cbzPath);
|
||||
$pagesDirectory = $chapter->getPagesDirectory();
|
||||
$filename = basename($pagesDirectory);
|
||||
|
||||
try {
|
||||
$httpResponse = $this->fileService->downloadCbz($cbzPath, $filename);
|
||||
$httpResponse = $this->fileService->downloadCbz($pagesDirectory, $filename);
|
||||
} catch (CbzFileNotFoundException $e) {
|
||||
throw new ChapterNotAvailableException($query->chapterId);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Domain\Manga\Application\QueryHandler;
|
||||
|
||||
use App\Domain\Manga\Application\Query\DownloadVolume;
|
||||
use App\Domain\Manga\Application\Response\DownloadResponse;
|
||||
use App\Domain\Manga\Domain\Contract\Repository\ChapterRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Contract\Service\FileServiceInterface;
|
||||
use App\Domain\Manga\Domain\Exception\MangaNotFoundException;
|
||||
@@ -16,7 +15,6 @@ use App\Domain\Shared\Domain\Contract\ResponseInterface;
|
||||
readonly class DownloadVolumeHandler implements QueryHandlerInterface
|
||||
{
|
||||
public function __construct(
|
||||
private ChapterRepositoryInterface $chapterRepository,
|
||||
private MangaRepositoryInterface $mangaRepository,
|
||||
private FileServiceInterface $fileService
|
||||
) {
|
||||
@@ -32,7 +30,7 @@ readonly class DownloadVolumeHandler implements QueryHandlerInterface
|
||||
throw new MangaNotFoundException($query->mangaId);
|
||||
}
|
||||
|
||||
$chapters = $this->chapterRepository->findVisibleWithCbzByMangaIdAndVolume(
|
||||
$chapters = $this->mangaRepository->findVisibleChaptersWithPagesByMangaIdAndVolume(
|
||||
$query->mangaId,
|
||||
$query->volume
|
||||
);
|
||||
@@ -41,10 +39,9 @@ readonly class DownloadVolumeHandler implements QueryHandlerInterface
|
||||
throw new VolumeNotFoundException($query->mangaId, $query->volume);
|
||||
}
|
||||
|
||||
// Collect CBZ paths for all chapters
|
||||
$cbzPaths = [];
|
||||
foreach ($chapters as $chapter) {
|
||||
$cbzPaths[] = $chapter->getCbzPath();
|
||||
$cbzPaths[] = $chapter->getPagesDirectory();
|
||||
}
|
||||
|
||||
$volumeName = sprintf(
|
||||
|
||||
@@ -40,8 +40,8 @@ readonly class GetMangaChaptersHandler
|
||||
title: $chapter->getTitle(),
|
||||
volume: $chapter->getVolume(),
|
||||
isVisible: $chapter->isVisible(),
|
||||
cbzPath: $chapter->getCbzPath(),
|
||||
createdAt: $chapter->getCreatedAt()
|
||||
pagesDirectory: $chapter->getPagesDirectory(),
|
||||
createdAt: $chapter->getCreatedAt()->format(\DateTimeInterface::RFC3339)
|
||||
),
|
||||
$chapters
|
||||
),
|
||||
|
||||
@@ -10,8 +10,8 @@ readonly class ChapterResponse
|
||||
public ?string $title,
|
||||
public ?int $volume,
|
||||
public bool $isVisible,
|
||||
public ?string $cbzPath,
|
||||
public \DateTimeImmutable $createdAt
|
||||
public ?string $pagesDirectory,
|
||||
public string $createdAt
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user