Compare commits

...

4 Commits

Author SHA1 Message Date
skn
662f0f29cb Merge 29771a5329 into dbab3c1041 2025-07-02 20:45:03 +04:00
dbab3c1041 Merge pull request #8290 from wallabag/fix-pocket-csv-controller
Fix PocketCsvController to extend AbstractController
2025-07-02 16:22:37 +02:00
42c87ab1d7 Fix PocketCsvController to extend AbstractController 2025-07-02 16:07:17 +02:00
29771a5329 PHP-CS-Fixer cleanup 2025-07-02 17:38:16 +04:00
2 changed files with 56 additions and 3 deletions

View File

@ -8,10 +8,12 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
use Wallabag\Controller\AbstractController;
use Wallabag\Form\Type\UploadImportType;
use Wallabag\Import\PocketCsvImport;
use Wallabag\Redis\Producer as RedisProducer;
class PocketCsvController extends HtmlController
class PocketCsvController extends AbstractController
{
public function __construct(
private readonly PocketCsvImport $pocketCsvImport,
@ -25,7 +27,58 @@ class PocketCsvController extends HtmlController
#[IsGranted('IMPORT_ENTRIES')]
public function indexAction(Request $request, TranslatorInterface $translator)
{
return parent::indexAction($request, $translator);
$form = $this->createForm(UploadImportType::class);
$form->handleRequest($request);
$this->pocketCsvImport->setUser($this->getUser());
if ($this->craueConfig->get('import_with_rabbitmq')) {
$this->pocketCsvImport->setProducer($this->rabbitMqProducer);
} elseif ($this->craueConfig->get('import_with_redis')) {
$this->pocketCsvImport->setProducer($this->redisProducer);
}
if ($form->isSubmitted() && $form->isValid()) {
$file = $form->get('file')->getData();
$markAsRead = $form->get('mark_as_read')->getData();
$name = 'pocket_' . $this->getUser()->getId() . '.csv';
if (null !== $file && \in_array($file->getClientMimeType(), $this->getParameter('wallabag.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag.resource_dir'), $name)) {
$res = $this->pocketCsvImport
->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name)
->setMarkAsRead($markAsRead)
->import();
$message = 'flashes.import.notice.failed';
if (true === $res) {
$summary = $this->pocketCsvImport->getSummary();
$message = $translator->trans('flashes.import.notice.summary', [
'%imported%' => $summary['imported'],
'%skipped%' => $summary['skipped'],
]);
if (0 < $summary['queued']) {
$message = $translator->trans('flashes.import.notice.summary_with_queue', [
'%queued%' => $summary['queued'],
]);
}
unlink($this->getParameter('wallabag.resource_dir') . '/' . $name);
}
$this->addFlash('notice', $message);
return $this->redirect($this->generateUrl('homepage'));
}
$this->addFlash('notice', 'flashes.import.notice.failed_on_file');
}
return $this->render('Import/PocketCsv/index.html.twig', [
'form' => $form->createView(),
'import' => $this->pocketCsvImport,
]);
}
protected function getImportService()

View File

@ -268,7 +268,7 @@ class EntryRepository extends ServiceEntityRepository
* @param string $order
* @param int $since
* @param string $tags
* @param string $detail 'metadata' or 'full'. Include content field if 'full'
* @param string $detail 'metadata' or 'full'. Include content field if 'full'
* @param string $domainName
* @param int $httpStatus
* @param bool $isNotParsed