Skip to content

Commit

Permalink
add databox_id and record_id in workerRunningJob
Browse files Browse the repository at this point in the history
  • Loading branch information
aynsix committed Apr 29, 2024
1 parent 2c412ec commit bac310d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lib/Alchemy/Phrasea/WorkerManager/Worker/WebhookWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -85,7 +99,6 @@ public function process(array $payload)
$em->rollback();
}

$webhookEventId = $payload['id'];
$app = $this->app;

$version = new Version();
Expand All @@ -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);

Expand Down

0 comments on commit bac310d

Please sign in to comment.