mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-08 18:44:30 +00:00

* WIP/POC DO NOT MERGE use "pusher" to wait for export-by-email worker to tell client that export is done. nb: export worker is artificially delayed by 30s ! * WIP OK TO TEST ; DO NOT MERGE * WIP/POC DO NOT MERGE use "pusher" to wait for export-by-email worker to tell client that export is done. nb: export worker is artificially delayed by 30s ! * WIP OK TO TEST ; DO NOT MERGE * cleanup * cleanup * better conf & cleanup * fix typo * fix stamp transparency (bump imagine) fix missing cgu for one file download better cli feedback add (re)download link on cli * fix test * fix missing js feedback (when worker publish before client subscribes) * cleanup * fix "remove stamp" choice * add default conf * WIP/POC DO NOT MERGE use "pusher" to wait for export-by-email worker to tell client that export is done. nb: export worker is artificially delayed by 30s ! * WIP OK TO TEST ; DO NOT MERGE * WIP/POC DO NOT MERGE use "pusher" to wait for export-by-email worker to tell client that export is done. nb: export worker is artificially delayed by 30s ! * WIP OK TO TEST ; DO NOT MERGE * cleanup * cleanup * better conf & cleanup * fix typo * fix stamp transparency (bump imagine) fix missing cgu for one file download better cli feedback add (re)download link on cli * fix test * fix missing js feedback (when worker publish before client subscribes) * cleanup * fix "remove stamp" choice * add default conf * WIP OK TO TEST generates an excel report for async download. define some env-vars for Pusher (todo: fix entrypoint to add during install) * fix xl formating for tabs >1 add env_vars to config build * fix test
98 lines
3.3 KiB
PHP
98 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace Alchemy\Phrasea\WorkerManager\Subscriber;
|
|
|
|
use Alchemy\Phrasea\Core\Event\DownloadAsyncEvent;
|
|
use Alchemy\Phrasea\Core\Event\ExportMailEvent;
|
|
use Alchemy\Phrasea\Core\PhraseaEvents;
|
|
use Alchemy\Phrasea\WorkerManager\Event\ExportFtpEvent;
|
|
use Alchemy\Phrasea\WorkerManager\Event\ExportMailFailureEvent;
|
|
use Alchemy\Phrasea\WorkerManager\Event\WorkerEvents;
|
|
use Alchemy\Phrasea\WorkerManager\Queue\MessagePublisher;
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|
|
|
class ExportSubscriber implements EventSubscriberInterface
|
|
{
|
|
/** @var MessagePublisher $messagePublisher */
|
|
private $messagePublisher;
|
|
|
|
public function __construct(MessagePublisher $messagePublisher)
|
|
{
|
|
$this->messagePublisher = $messagePublisher;
|
|
}
|
|
|
|
public function onDownloadAsyncCreate(DownloadAsyncEvent $event)
|
|
{
|
|
$payload = [
|
|
'message_type' => MessagePublisher::DOWNLOAD_ASYNC_TYPE,
|
|
'payload' => [
|
|
'userId' => $event->getUserId(),
|
|
'tokenValue' => $event->getTokenValue(),
|
|
'params' => serialize($event->getParams())
|
|
]
|
|
];
|
|
|
|
$this->messagePublisher->publishMessage($payload, MessagePublisher::DOWNLOAD_ASYNC_TYPE);
|
|
}
|
|
|
|
public function onExportMailCreate(ExportMailEvent $event)
|
|
{
|
|
$payload = [
|
|
'message_type' => MessagePublisher::EXPORT_MAIL_TYPE,
|
|
'payload' => [
|
|
'emitterUserId' => $event->getEmitterUserId(),
|
|
'tokenValue' => $event->getTokenValue(),
|
|
'destinationMails' => serialize($event->getDestinationMails()),
|
|
'params' => serialize($event->getParams())
|
|
]
|
|
];
|
|
|
|
$this->messagePublisher->publishMessage($payload, MessagePublisher::EXPORT_MAIL_TYPE);
|
|
}
|
|
|
|
public function onExportMailFailure(ExportMailFailureEvent $event)
|
|
{
|
|
$payload = [
|
|
'message_type' => MessagePublisher::EXPORT_MAIL_TYPE,
|
|
'payload' => [
|
|
'emitterUserId' => $event->getEmitterUserId(),
|
|
'tokenValue' => $event->getTokenValue(),
|
|
'destinationMails' => serialize($event->getDestinationMails()),
|
|
'params' => serialize($event->getParams())
|
|
]
|
|
];
|
|
|
|
$this->messagePublisher->publishRetryMessage(
|
|
$payload,
|
|
MessagePublisher::EXPORT_MAIL_TYPE,
|
|
$event->getCount(),
|
|
$event->getWorkerMessage()
|
|
);
|
|
}
|
|
|
|
public function onExportFtp(ExportFtpEvent $event)
|
|
{
|
|
$payload = [
|
|
'message_type' => MessagePublisher::FTP_TYPE,
|
|
'payload' => [
|
|
'ftpExportId' => $event->getFtpExportId(),
|
|
]
|
|
];
|
|
|
|
$this->messagePublisher->publishMessage(
|
|
$payload,
|
|
MessagePublisher::FTP_TYPE
|
|
);
|
|
}
|
|
|
|
public static function getSubscribedEvents()
|
|
{
|
|
return [
|
|
PhraseaEvents::DOWNLOAD_ASYNC_CREATE => 'onDownloadAsyncCreate',
|
|
PhraseaEvents::EXPORT_MAIL_CREATE => 'onExportMailCreate',
|
|
WorkerEvents::EXPORT_MAIL_FAILURE => 'onExportMailFailure',
|
|
WorkerEvents::EXPORT_FTP => 'onExportFtp'
|
|
];
|
|
}
|
|
}
|