Skip to content

Commit

Permalink
better conf & cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jygaulier committed Oct 12, 2023
1 parent 8e44279 commit b6a497d
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 66 deletions.
3 changes: 2 additions & 1 deletion config/configuration.sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lib/Alchemy/Phrasea/Controller/Prod/DownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down
58 changes: 0 additions & 58 deletions lib/Alchemy/Phrasea/Controller/Prod/ExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
4 changes: 0 additions & 4 deletions lib/Alchemy/Phrasea/ControllerProvider/Prod/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/web/common/dialog_export.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<div id="download">
<div style="padding:10px; text-align: center;">
<h4>{{ 'export:: telechargement' | trans }}</h4>
{% 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 %}
Expand Down

0 comments on commit b6a497d

Please sign in to comment.