Skip to content

Commit a80a1ec

Browse files
authored
Merge pull request #271 from laravel-workflow/fix-webhook-url-mismatch
Fix webhook URL generation to include workflow slug
2 parents 3eb04ad + a5d599f commit a80a1ec

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/Activity.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,14 @@ public function workflowId()
7777
public function webhookUrl(string $signalMethod = ''): string
7878
{
7979
$basePath = config('workflows.webhooks_route', '/webhooks');
80+
$workflow = Str::kebab(class_basename($this->storedWorkflow->class));
81+
8082
if ($signalMethod === '') {
81-
$workflow = Str::kebab(class_basename($this->storedWorkflow->class));
8283
return url("{$basePath}/{$workflow}");
8384
}
85+
8486
$signal = Str::kebab($signalMethod);
85-
return url("{$basePath}/signal/{$this->storedWorkflow->id}/{$signal}");
87+
return url("{$basePath}/signal/{$workflow}/{$this->storedWorkflow->id}/{$signal}");
8688
}
8789

8890
public function handle()

tests/Unit/ActivityTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,6 @@ public function testWebhookUrl(): void
131131
]);
132132

133133
$this->assertSame('http://localhost/webhooks/test-workflow', $activity->webhookUrl());
134-
$this->assertSame('http://localhost/webhooks/signal/1/other', $activity->webhookUrl('other'));
134+
$this->assertSame('http://localhost/webhooks/signal/test-workflow/1/other', $activity->webhookUrl('other'));
135135
}
136136
}

0 commit comments

Comments
 (0)