Skip to content

Commit

Permalink
fix(webhooks): always refresh base url on regeneration of webhooks (#293
Browse files Browse the repository at this point in the history
)

INT-591
  • Loading branch information
EdieLemoine authored Aug 15, 2024
1 parent aa0c458 commit 43917b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 2 additions & 6 deletions src/App/Action/Backend/Webhook/CreateWebhooksAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,9 @@ private function getRequestHooks(Request $request): array
*/
private function getWebhookUrl(Request $request): string
{
$url = $this->pdkWebhooksRepository->getHashedUrl();
$url = $this->webhookActions->createUrl();

if (! $url || $request->get('refresh', false)) {
$url = $this->webhookActions->createUrl();

$this->pdkWebhooksRepository->storeHashedUrl($url);
}
$this->pdkWebhooksRepository->storeHashedUrl($url);

return $url;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function createWebhooks(array $options): void
});
});

it('can refresh the url', function () {
it('refreshes the url on each generation', function () {
/** @var \MyParcelNL\Pdk\App\Webhook\Contract\PdkWebhooksRepositoryInterface $repo */
$repo = Pdk::get(PdkWebhooksRepositoryInterface::class);

Expand All @@ -98,7 +98,7 @@ function createWebhooks(array $options): void
$oldWebhooks = $repo->getAll();
$oldUrl = $oldWebhooks->first()->url;

createWebhooks(['hooks' => WebhookSubscription::SHIPMENT_STATUS_CHANGE, 'refresh' => true]);
createWebhooks(['hooks' => WebhookSubscription::SHIPMENT_STATUS_CHANGE]);

$allWebhooks = $repo->getAll();

Expand Down

0 comments on commit 43917b2

Please sign in to comment.