From b6a497dfe33cf49f54cf403a7149760d17008df6 Mon Sep 17 00:00:00 2001 From: jygaulier Date: Thu, 12 Oct 2023 10:25:26 +0200 Subject: [PATCH] better conf & cleanup --- config/configuration.sample.yml | 3 +- .../Controller/Prod/DownloadController.php | 2 +- .../Controller/Prod/ExportController.php | 58 ------------------- .../ControllerProvider/Prod/Export.php | 4 -- .../Worker/DownloadAsyncWorker.php | 2 +- templates/web/common/dialog_export.html.twig | 2 +- 6 files changed, 5 insertions(+), 66 deletions(-) diff --git a/config/configuration.sample.yml b/config/configuration.sample.yml index d68fb0eab7..9173e61f5b 100644 --- a/config/configuration.sample.yml +++ b/config/configuration.sample.yml @@ -244,8 +244,9 @@ registration-fields: - name: geonameid required: true +download_async: + enabled: true pusher: - enabled: false auth_key: 'pusher-auth_key' secret: 'pusher-secret' app_id: 'pusher-app_id' diff --git a/lib/Alchemy/Phrasea/Controller/Prod/DownloadController.php b/lib/Alchemy/Phrasea/Controller/Prod/DownloadController.php index d4ddfa74d0..9340a45398 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/DownloadController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/DownloadController.php @@ -137,7 +137,7 @@ public function checkDownloadAsync(Request $request) ] )); - $pusher_auth_key =$this->getConf()->get(['pusher', 'enabled'], false) ? $this->getConf()->get(['pusher', 'auth_key'], '') : null; + $pusher_auth_key =$this->getConf()->get(['download_async', 'enabled'], false) ? $this->getConf()->get(['pusher', 'auth_key'], '') : null; return new Response($this->render( /** @uses templates/web/prod/actions/Download/prepare_async.html.twig */ '/prod/actions/Download/prepare_async.html.twig', [ diff --git a/lib/Alchemy/Phrasea/Controller/Prod/ExportController.php b/lib/Alchemy/Phrasea/Controller/Prod/ExportController.php index e939b86ac9..4ef91b65c5 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/ExportController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/ExportController.php @@ -154,64 +154,6 @@ public function exportFtp(Request $request) } } - /** - * Async Export - * - * @param Request $request - * @return JsonResponse - */ - public function exportAsync(Request $request) - { - if (!$this->isCrsfValid($request, 'prodExportEmail')) { - return $this->app->json(['message' => 'invalid export mail form'], 403); - } - - set_time_limit(0); - session_write_close(); - ignore_user_abort(true); - - $lst = $request->request->get('lst', ''); - $ssttid = $request->request->get('ssttid', ''); - - //prepare export - $download = new \set_export($this->app, $lst, $ssttid); - $list = $download->prepare_export( - $this->getAuthenticatedUser(), - $this->getFilesystem(), - (array) $request->request->get('obj'), - $request->request->get("type") == "title" ? : false, - $request->request->get('businessfields'), - $request->request->get('stamp_choice') === "NO_STAMP" ? \set_export::NO_STAMP : \set_export::STAMP_ASYNC, - true - ); - - $list['export_name'] = sprintf("%s.zip", $download->getExportName()); - - $token = $this->getTokenManipulator()->createEmailExportToken(serialize($list)); - - $tokenValue = $token->getValue(); - - $url = $this->app->url('prepare_download', ['token' => $token->getValue(), 'anonymous' => false, 'type' => \Session_Logger::EVENT_EXPORTMAIL]); - - $params = [ - 'url' => $url, - 'textmail' => $request->request->get('textmail'), - 'reading_confirm' => !!$request->request->get('reading_confirm', false), - 'ssttid' => $ssttid = $request->request->get('ssttid', ''), - 'lst' => $lst = $request->request->get('lst', ''), - ]; - - $this->dispatch(PhraseaEvents::EXPORT_ASYNC_CREATE, new ExportAsyncEvent( - $tokenValue, - $params - )); - - return $this->app->json([ - 'success' => true, - 'message' => '' - ]); - } - /** * Export document by mail * diff --git a/lib/Alchemy/Phrasea/ControllerProvider/Prod/Export.php b/lib/Alchemy/Phrasea/ControllerProvider/Prod/Export.php index a952f3eba1..b6326e6270 100644 --- a/lib/Alchemy/Phrasea/ControllerProvider/Prod/Export.php +++ b/lib/Alchemy/Phrasea/ControllerProvider/Prod/Export.php @@ -57,10 +57,6 @@ public function connect(Application $app) $controllers->post('/mail/', 'controller.prod.export:exportMail') ->bind('export_mail'); - /** @uses ExportController::exportAsync */ - $controllers->post('/async/', 'controller.prod.export:exportAsync') - ->bind('export_async'); - /** @uses ExportController::exportFtp */ $controllers->post('/ftp/', 'controller.prod.export:exportFtp') ->bind('export_ftp'); diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/DownloadAsyncWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/DownloadAsyncWorker.php index fc7785bba3..6ae8f5cc8e 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/DownloadAsyncWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/DownloadAsyncWorker.php @@ -87,7 +87,7 @@ public function process(array $payload) /** @var Token $token */ $token = $tokenRepository->findValidToken($payload['tokenValue']); - if($this->conf->get(['pusher', 'enabled'], false)) { + if($this->conf->get(['downloas_async', 'enabled'], false)) { $options = array( 'cluster' => 'eu', 'useTLS' => true diff --git a/templates/web/common/dialog_export.html.twig b/templates/web/common/dialog_export.html.twig index 36502f10c3..4486ea1844 100644 --- a/templates/web/common/dialog_export.html.twig +++ b/templates/web/common/dialog_export.html.twig @@ -109,7 +109,7 @@

{{ 'export:: telechargement' | trans }}

- {% if app['conf'].get(['pusher', 'enabled'], false) %} + {% if app['conf'].get(['download_async', 'enabled'], false) %} {# \Alchemy\Phrasea\Controller\Prod\DownloadController::checkDownloadAsync #} {% set download_path = 'check_download_async' %} {% else %}