Integration cleanings (#366)

Co-authored-by: Forms Dev <chirag+new@notionforms.io>
This commit is contained in:
Chirag Chhatrala 2024-04-02 16:59:00 +05:30 committed by GitHub
parent b93f421e39
commit 615ac88f89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 49 additions and 308 deletions

View File

@ -1,38 +0,0 @@
<?php
namespace App\Listeners;
use App\Notifications\Forms\FailedWebhookNotification;
use Spatie\WebhookServer\Events\WebhookCallFailedEvent;
class FailedWebhookListener
{
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle(WebhookCallFailedEvent $event)
{
ray('in faieled', $event);
// Notify form owner
if ($event->meta['type'] == 'form_submission') {
$event->meta['form']->creator->notify(new FailedWebhookNotification($event));
\Log::error('Failed form submission webhook', [
'webhook_url' => $event->webhookUrl,
'exception' => $event->errorType,
'message' => $event->errorMessage,
'form_id' => $event->meta['form']->id,
]);
return;
}
\Log::error('Failed webhook', [
'webhook_url' => $event->webhookUrl,
'exception' => $event->errorType,
'message' => $event->errorMessage,
]);
}
}

View File

@ -1,57 +0,0 @@
<?php
namespace App\Notifications\Forms;
use App\Models\Forms\Form;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Spatie\WebhookServer\Events\WebhookCallFailedEvent;
class FailedWebhookNotification extends Notification
{
use Queueable;
public Form $form;
public string $provider;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(protected WebhookCallFailedEvent $event)
{
$this->form = $this->event->meta['form'];
$this->provider = $this->event->meta['provider'];
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage())
->subject("Notification issue with your NotionForm: '".$this->form->title."'")
->markdown('mail.form.webhook-error', [
'provider' => $this->provider,
'error' => $this->event->errorMessage,
'form' => $this->form,
]);
}
}

View File

@ -5,14 +5,12 @@ namespace App\Providers;
use App\Events\Forms\FormSubmitted; use App\Events\Forms\FormSubmitted;
use App\Events\Models\FormCreated; use App\Events\Models\FormCreated;
use App\Events\Models\FormIntegrationsEventCreated; use App\Events\Models\FormIntegrationsEventCreated;
use App\Listeners\FailedWebhookListener;
use App\Listeners\Forms\FormCreationConfirmation; use App\Listeners\Forms\FormCreationConfirmation;
use App\Listeners\Forms\FormIntegrationsEventListener; use App\Listeners\Forms\FormIntegrationsEventListener;
use App\Listeners\Forms\NotifyFormSubmission; use App\Listeners\Forms\NotifyFormSubmission;
use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification; use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Spatie\WebhookServer\Events\WebhookCallFailedEvent;
class EventServiceProvider extends ServiceProvider class EventServiceProvider extends ServiceProvider
{ {
@ -31,9 +29,6 @@ class EventServiceProvider extends ServiceProvider
FormSubmitted::class => [ FormSubmitted::class => [
NotifyFormSubmission::class NotifyFormSubmission::class
], ],
WebhookCallFailedEvent::class => [
FailedWebhookListener::class,
],
FormIntegrationsEventCreated::class => [ FormIntegrationsEventCreated::class => [
FormIntegrationsEventListener::class, FormIntegrationsEventListener::class,
], ],

View File

@ -35,7 +35,6 @@
"sentry/sentry-laravel": "^2.11.0", "sentry/sentry-laravel": "^2.11.0",
"spatie/laravel-sitemap": "^6.0", "spatie/laravel-sitemap": "^6.0",
"spatie/laravel-sluggable": "^3.0", "spatie/laravel-sluggable": "^3.0",
"spatie/laravel-webhook-server": "^3.1.2",
"stevebauman/purify": "^v6.2.0", "stevebauman/purify": "^v6.2.0",
"tymon/jwt-auth": "^1.0.2", "tymon/jwt-auth": "^1.0.2",
"vinkla/hashids": "^10.0" "vinkla/hashids": "^10.0"

170
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "4650817c0a533e9c119951b658245999", "content-hash": "6d742b79739f9d1ca839f2b9c52aaa8f",
"packages": [ "packages": [
{ {
"name": "aws/aws-crt-php", "name": "aws/aws-crt-php",
@ -62,16 +62,16 @@
}, },
{ {
"name": "aws/aws-sdk-php", "name": "aws/aws-sdk-php",
"version": "3.301.7", "version": "3.303.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/aws/aws-sdk-php.git", "url": "https://github.com/aws/aws-sdk-php.git",
"reference": "2fd8cae93e87326f2263c420fa9031ad8903a2f2" "reference": "34ace61fdffcea032826b0aac61ff3135b24b727"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/2fd8cae93e87326f2263c420fa9031ad8903a2f2", "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/34ace61fdffcea032826b0aac61ff3135b24b727",
"reference": "2fd8cae93e87326f2263c420fa9031ad8903a2f2", "reference": "34ace61fdffcea032826b0aac61ff3135b24b727",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -151,9 +151,9 @@
"support": { "support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues", "issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.301.7" "source": "https://github.com/aws/aws-sdk-php/tree/3.303.0"
}, },
"time": "2024-03-25T18:14:28+00:00" "time": "2024-04-01T18:48:47+00:00"
}, },
{ {
"name": "brick/math", "name": "brick/math",
@ -2682,16 +2682,16 @@
}, },
{ {
"name": "laravel/horizon", "name": "laravel/horizon",
"version": "v5.23.1", "version": "v5.23.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/horizon.git", "url": "https://github.com/laravel/horizon.git",
"reference": "7475de7eb5b465c2da84218002fe1a62b8175da0" "reference": "96d154340f1223bcc161ea7cee355c8fc29ff81e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/horizon/zipball/7475de7eb5b465c2da84218002fe1a62b8175da0", "url": "https://api.github.com/repos/laravel/horizon/zipball/96d154340f1223bcc161ea7cee355c8fc29ff81e",
"reference": "7475de7eb5b465c2da84218002fe1a62b8175da0", "reference": "96d154340f1223bcc161ea7cee355c8fc29ff81e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2704,6 +2704,7 @@
"nesbot/carbon": "^2.17|^3.0", "nesbot/carbon": "^2.17|^3.0",
"php": "^8.0", "php": "^8.0",
"ramsey/uuid": "^4.0", "ramsey/uuid": "^4.0",
"symfony/console": "^6.0|^7.0",
"symfony/error-handler": "^6.0|^7.0", "symfony/error-handler": "^6.0|^7.0",
"symfony/process": "^6.0|^7.0" "symfony/process": "^6.0|^7.0"
}, },
@ -2754,9 +2755,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/laravel/horizon/issues", "issues": "https://github.com/laravel/horizon/issues",
"source": "https://github.com/laravel/horizon/tree/v5.23.1" "source": "https://github.com/laravel/horizon/tree/v5.23.2"
}, },
"time": "2024-02-20T15:14:10+00:00" "time": "2024-03-23T12:11:34+00:00"
}, },
{ {
"name": "laravel/serializable-closure", "name": "laravel/serializable-closure",
@ -3086,16 +3087,16 @@
}, },
{ {
"name": "laravel/vapor-core", "name": "laravel/vapor-core",
"version": "v2.37.0", "version": "v2.37.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/vapor-core.git", "url": "https://github.com/laravel/vapor-core.git",
"reference": "03ec602ca43ff780f2924a9be8bb944ed960813f" "reference": "9fac8cd0f9b6979887253dd676e04ecb868be615"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/vapor-core/zipball/03ec602ca43ff780f2924a9be8bb944ed960813f", "url": "https://api.github.com/repos/laravel/vapor-core/zipball/9fac8cd0f9b6979887253dd676e04ecb868be615",
"reference": "03ec602ca43ff780f2924a9be8bb944ed960813f", "reference": "9fac8cd0f9b6979887253dd676e04ecb868be615",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3159,9 +3160,9 @@
"vapor" "vapor"
], ],
"support": { "support": {
"source": "https://github.com/laravel/vapor-core/tree/v2.37.0" "source": "https://github.com/laravel/vapor-core/tree/v2.37.1"
}, },
"time": "2024-02-16T17:41:53+00:00" "time": "2024-03-26T16:55:06+00:00"
}, },
{ {
"name": "laravel/vapor-ui", "name": "laravel/vapor-ui",
@ -5401,16 +5402,16 @@
}, },
{ {
"name": "php-http/discovery", "name": "php-http/discovery",
"version": "1.19.2", "version": "1.19.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-http/discovery.git", "url": "https://github.com/php-http/discovery.git",
"reference": "61e1a1eb69c92741f5896d9e05fb8e9d7e8bb0cb" "reference": "0700efda8d7526335132360167315fdab3aeb599"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-http/discovery/zipball/61e1a1eb69c92741f5896d9e05fb8e9d7e8bb0cb", "url": "https://api.github.com/repos/php-http/discovery/zipball/0700efda8d7526335132360167315fdab3aeb599",
"reference": "61e1a1eb69c92741f5896d9e05fb8e9d7e8bb0cb", "reference": "0700efda8d7526335132360167315fdab3aeb599",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -5434,7 +5435,8 @@
"php-http/httplug": "^1.0 || ^2.0", "php-http/httplug": "^1.0 || ^2.0",
"php-http/message-factory": "^1.0", "php-http/message-factory": "^1.0",
"phpspec/phpspec": "^5.1 || ^6.1 || ^7.3", "phpspec/phpspec": "^5.1 || ^6.1 || ^7.3",
"symfony/phpunit-bridge": "^6.2" "sebastian/comparator": "^3.0.5 || ^4.0.8",
"symfony/phpunit-bridge": "^6.4.4 || ^7.0.1"
}, },
"type": "composer-plugin", "type": "composer-plugin",
"extra": { "extra": {
@ -5473,9 +5475,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/php-http/discovery/issues", "issues": "https://github.com/php-http/discovery/issues",
"source": "https://github.com/php-http/discovery/tree/1.19.2" "source": "https://github.com/php-http/discovery/tree/1.19.4"
}, },
"time": "2023-11-30T16:49:05+00:00" "time": "2024-03-29T13:00:05+00:00"
}, },
{ {
"name": "php-http/httplug", "name": "php-http/httplug",
@ -7603,80 +7605,6 @@
], ],
"time": "2024-02-26T08:33:29+00:00" "time": "2024-02-26T08:33:29+00:00"
}, },
{
"name": "spatie/laravel-webhook-server",
"version": "3.8.1",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-webhook-server.git",
"reference": "d4cc24141a4d6a148e110df5f36217cc8f40f07e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-webhook-server/zipball/d4cc24141a4d6a148e110df5f36217cc8f40f07e",
"reference": "d4cc24141a4d6a148e110df5f36217cc8f40f07e",
"shasum": ""
},
"require": {
"ext-json": "*",
"guzzlehttp/guzzle": "^6.3|^7.3",
"illuminate/bus": "^8.50|^9.0|^10.0|^11.0",
"illuminate/queue": "^8.50|^9.0|^10.0|^11.0",
"illuminate/support": "^8.50|^9.0|^10.0|^11.0",
"php": "^8.0",
"spatie/laravel-package-tools": "^1.11"
},
"require-dev": {
"mockery/mockery": "^1.4.3",
"orchestra/testbench": "^6.19|^7.0|^8.0",
"pestphp/pest": "^1.22|^2.0",
"pestphp/pest-plugin-laravel": "^1.3|^2.0",
"spatie/test-time": "^1.2.2"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Spatie\\WebhookServer\\WebhookServerServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Spatie\\WebhookServer\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Send webhooks in Laravel apps",
"homepage": "https://github.com/spatie/laravel-webhook-server",
"keywords": [
"laravel-webhook-server",
"server",
"spatie",
"webhook"
],
"support": {
"source": "https://github.com/spatie/laravel-webhook-server/tree/3.8.1"
},
"funding": [
{
"url": "https://spatie.be/open-source/support-us",
"type": "custom"
}
],
"time": "2024-02-12T08:18:25+00:00"
},
{ {
"name": "spatie/robots-txt", "name": "spatie/robots-txt",
"version": "2.0.3", "version": "2.0.3",
@ -11971,16 +11899,16 @@
}, },
{ {
"name": "laravel/pint", "name": "laravel/pint",
"version": "v1.14.0", "version": "v1.15.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/pint.git", "url": "https://github.com/laravel/pint.git",
"reference": "6b127276e3f263f7bb17d5077e9e0269e61b2a0e" "reference": "c52de679b3ac01207016c179d7ce173e4be128c4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/pint/zipball/6b127276e3f263f7bb17d5077e9e0269e61b2a0e", "url": "https://api.github.com/repos/laravel/pint/zipball/c52de679b3ac01207016c179d7ce173e4be128c4",
"reference": "6b127276e3f263f7bb17d5077e9e0269e61b2a0e", "reference": "c52de679b3ac01207016c179d7ce173e4be128c4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -12033,7 +11961,7 @@
"issues": "https://github.com/laravel/pint/issues", "issues": "https://github.com/laravel/pint/issues",
"source": "https://github.com/laravel/pint" "source": "https://github.com/laravel/pint"
}, },
"time": "2024-02-20T17:38:05+00:00" "time": "2024-03-26T16:40:24+00:00"
}, },
{ {
"name": "laravel/sail", "name": "laravel/sail",
@ -13072,16 +13000,16 @@
}, },
{ {
"name": "phpstan/phpstan", "name": "phpstan/phpstan",
"version": "1.10.65", "version": "1.10.66",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan.git", "url": "https://github.com/phpstan/phpstan.git",
"reference": "3c657d057a0b7ecae19cb12db446bbc99d8839c6" "reference": "94779c987e4ebd620025d9e5fdd23323903950bd"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/3c657d057a0b7ecae19cb12db446bbc99d8839c6", "url": "https://api.github.com/repos/phpstan/phpstan/zipball/94779c987e4ebd620025d9e5fdd23323903950bd",
"reference": "3c657d057a0b7ecae19cb12db446bbc99d8839c6", "reference": "94779c987e4ebd620025d9e5fdd23323903950bd",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -13130,7 +13058,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-03-23T10:30:26+00:00" "time": "2024-03-28T16:17:31+00:00"
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
@ -14759,16 +14687,16 @@
}, },
{ {
"name": "spatie/ignition", "name": "spatie/ignition",
"version": "1.12.0", "version": "1.13.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/spatie/ignition.git", "url": "https://github.com/spatie/ignition.git",
"reference": "5b6f801c605a593106b623e45ca41496a6e7d56d" "reference": "889bf1dfa59e161590f677728b47bf4a6893983b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/spatie/ignition/zipball/5b6f801c605a593106b623e45ca41496a6e7d56d", "url": "https://api.github.com/repos/spatie/ignition/zipball/889bf1dfa59e161590f677728b47bf4a6893983b",
"reference": "5b6f801c605a593106b623e45ca41496a6e7d56d", "reference": "889bf1dfa59e161590f677728b47bf4a6893983b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -14838,7 +14766,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2024-01-03T15:49:39+00:00" "time": "2024-03-29T14:03:47+00:00"
}, },
{ {
"name": "spatie/laravel-ignition", "name": "spatie/laravel-ignition",
@ -14932,16 +14860,16 @@
}, },
{ {
"name": "spatie/laravel-ray", "name": "spatie/laravel-ray",
"version": "1.35.1", "version": "1.36.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/spatie/laravel-ray.git", "url": "https://github.com/spatie/laravel-ray.git",
"reference": "f504d3787d88c7e5de7a4290658f7ad9b1352f22" "reference": "f15936b5d308ae391ee67370a5628f0712537c34"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-ray/zipball/f504d3787d88c7e5de7a4290658f7ad9b1352f22", "url": "https://api.github.com/repos/spatie/laravel-ray/zipball/f15936b5d308ae391ee67370a5628f0712537c34",
"reference": "f504d3787d88c7e5de7a4290658f7ad9b1352f22", "reference": "f15936b5d308ae391ee67370a5628f0712537c34",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -15003,7 +14931,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/spatie/laravel-ray/issues", "issues": "https://github.com/spatie/laravel-ray/issues",
"source": "https://github.com/spatie/laravel-ray/tree/1.35.1" "source": "https://github.com/spatie/laravel-ray/tree/1.36.0"
}, },
"funding": [ "funding": [
{ {
@ -15015,7 +14943,7 @@
"type": "other" "type": "other"
} }
], ],
"time": "2024-02-13T14:19:41+00:00" "time": "2024-03-29T09:10:11+00:00"
}, },
{ {
"name": "spatie/macroable", "name": "spatie/macroable",

View File

@ -1,71 +0,0 @@
<?php
return [
/*
* The default queue that should be used to send webhook requests.
*/
'queue' => env('SQS_QUEUE', 'your-queue-name'),
/*
* The default queue connection that should be used to send webhook requests.
*/
'connection' => null,
/*
* The default http verb to use.
*/
'http_verb' => 'post',
/*
* This class is responsible for calculating the signature that will be added to
* the headers of the webhook request. A webhook client can use the signature
* to verify the request hasn't been tampered with.
*/
'signer' => \Spatie\WebhookServer\Signer\DefaultSigner::class,
/*
* This is the name of the header where the signature will be added.
*/
'signature_header_name' => 'Signature',
/*
* These are the headers that will be added to all webhook requests.
*/
'headers' => [
'Content-Type' => 'application/json',
],
/*
* If a call to a webhook takes longer that this amount of seconds
* the attempt will be considered failed.
*/
'timeout_in_seconds' => 3,
/*
* The amount of times the webhook should be called before we give up.
*/
'tries' => 3,
/*
* This class determines how many seconds there should be between attempts.
*/
'backoff_strategy' => \Spatie\WebhookServer\BackoffStrategy\ExponentialBackoffStrategy::class,
/*
* By default we will verify that the ssl certificate of the destination
* of the webhook is valid.
*/
'verify_ssl' => true,
/*
* When set to true, an exception will be thrown when the last attempt fails
*/
'throw_exception_on_failure' => false,
/*
* When using Laravel Horizon you can specify tags that should be used on the
* underlying job that performs the webhook request.
*/
'tags' => [],
];

View File

@ -1,15 +0,0 @@
@component('mail::message')
Hello,
We tried to trigger a **{{$provider}}** notification for your form "{{$form->title}}", but it failed. Here is the error that we got:
@component('mail::panel')
{{$error}}
@endcomponent
Click [here to edit your form]({{$form->edit_url}}).
Contact us via the website live chat if you need any help.
@endcomponent