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