Skip to content

Commit

Permalink
Merge branch '106-webhooks' of github.com:danjohnson95/cachet-core in…
Browse files Browse the repository at this point in the history
…to 106-webhooks
  • Loading branch information
danjohnson95 committed Jan 9, 2025
2 parents 909fb2d + a08dbea commit 31681a0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"spatie/laravel-query-builder": "^5.5",
"spatie/laravel-settings": "^3.2",
"spatie/laravel-webhook-server": "^3.8",
"timacdonald/json-api": "^v1.0.0-beta.4",
"timacdonald/json-api": "^1.0.0-beta.4",
"twig/twig": "^3.0"
},
"require-dev": {
Expand Down
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 31681a0

Please sign in to comment.