Skip to content

Commit

Permalink
Merge branch 'master' into PHRAS-4007-openid-provider
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaillat authored Apr 29, 2024
2 parents bcee582 + df780d9 commit b3238f2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
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 b3238f2

Please sign in to comment.