diff --git a/lib/Alchemy/Phrasea/Webhook/Processor/SubdefEventProcessor.php b/lib/Alchemy/Phrasea/Webhook/Processor/SubdefEventProcessor.php index 925fb7c253..33732d2b29 100644 --- a/lib/Alchemy/Phrasea/Webhook/Processor/SubdefEventProcessor.php +++ b/lib/Alchemy/Phrasea/Webhook/Processor/SubdefEventProcessor.php @@ -24,7 +24,7 @@ public function process(WebhookEvent $event) $record = $this->findDataboxById($data['databox_id'])->get_record($data['record_id']); $subdef = $record->get_subdef($data['subdef_name']); - if (empty($data['permalink'])) { + if (empty($data['permalink']) && $subdef->get_permalink() !== null) { $data['permalink'] = $subdef->get_permalink()->get_url()->__toString(); } diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/WebhookWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/WebhookWorker.php index 7e8a482921..593afbee5b 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/WebhookWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/WebhookWorker.php @@ -56,6 +56,12 @@ public function __construct(Application $app) public function process(array $payload) { if (isset($payload['id'])) { + $webhookEventId = $payload['id']; + + /** @var WebhookEvent|null $webhookevent */ + $webhookevent = $this->app['repo.webhook-event']->find($webhookEventId); + $wData = $webhookevent->getData(); + $this->repoWorkerJob = $this->getWorkerRunningJobRepository(); $em = $this->repoWorkerJob->getEntityManager(); $em->beginTransaction(); @@ -70,12 +76,20 @@ public function process(array $payload) $workerRunningJob = new WorkerRunningJob(); $workerRunningJob ->setWork(MessagePublisher::WEBHOOK_TYPE) - ->setWorkOn('WebhookEventId: '. $payload['id']) + ->setWorkOn($webhookevent->getName() . ' , WebhookEventId: '. $payload['id']) ->setPayload($message) ->setPublished($date->setTimestamp($payload['published'])) ->setStatus(WorkerRunningJob::RUNNING) ; + if (isset($wData['databox_id'])) { + $workerRunningJob->setDataboxId($wData['databox_id']); + } + + if (isset($wData['record_id'])) { + $workerRunningJob->setRecordId($wData['record_id']); + } + $em->persist($workerRunningJob); $em->flush(); @@ -85,7 +99,6 @@ public function process(array $payload) $em->rollback(); } - $webhookEventId = $payload['id']; $app = $this->app; $version = new Version(); @@ -107,9 +120,6 @@ public function process(array $payload) $thirdPartyApplications = $this->app['repo.api-applications']->findWithDefinedWebhookCallback(); - /** @var WebhookEvent|null $webhookevent */ - $webhookevent = $this->app['repo.webhook-event']->find($webhookEventId); - if ($webhookevent !== null) { $app['manipulator.webhook-event']->processed($webhookevent);