Skip to content

Commit

Permalink
Set user agent for webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrooksuk committed Jan 9, 2025
1 parent e99e3a2 commit a08dbea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Cachet.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ class Cachet
*/
public const USER_AGENT = 'Cachet/3.0 (+https://docs.cachethq.io)';

/**
* The user agent used by Cachet's webhooks.
*/
public const WEBHOOK_USER_AGENT = 'Cachet/3.0 Webhook (+https://docs.cachethq.io)';

/**
* Get the current user using `cachet.guard`.
*/
Expand Down
4 changes: 4 additions & 0 deletions src/Models/WebhookSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Cachet\Models;

use Cachet\Cachet;
use Cachet\Database\Factories\WebhookSubscriptionFactory;
use Cachet\Enums\WebhookEventEnum;
use Illuminate\Database\Eloquent\Builder;
Expand Down Expand Up @@ -62,6 +63,9 @@ public function makeCall(WebhookEventEnum $event, array $payload): WebhookCall
{
return WebhookCall::create()
->url($this->url)
->withHeaders([
'User-Agent' => Cachet::WEBHOOK_USER_AGENT,
])
->payload([
'event' => $event->value,
'body' => $payload,
Expand Down

0 comments on commit a08dbea

Please sign in to comment.