Notification & Integrations refactoring (#346)
* Integrations Refactoring - WIP * integrations list & edit - WIP * Fix integration store binding issue * integrations refactor - WIP * Form integration - WIP * Form integration Edit - WIP * Integration Refactor - Slack - WIP * Integration Refactor - Discord - WIP * Integration Refactor - Webhook - WIP * Integration Refactor - Send Submission Confirmation - WIP * Integration Refactor - Backend handler - WIP * Form Integration Status field * Integration Refactor - Backend SubmissionConfirmation - WIP * IntegrationMigration Command * skip confirmation email test case * Small refactoring * FormIntegration status active/inactive * formIntegrationData to integrationData * Rename file name with Integration suffix for integration realted files * Loader on form integrations * WIP * form integration test case * WIP * Added Integration card - working on refactoring * change location for IntegrationCard and update package file * Form Integration Create/Edit in single Modal * Remove integration extra pages * crisp_help_page_slug for integration json * integration logic as collapse * UI improvements * WIP * Trying to debug vue devtools * WIP for integrations * getIntegrationHandler change namespace name * useForm for integration fields + validation structure * Integration Test case & apply validation rules * Apply useform changes to integration other files * validation rules for FormNotificationsMessageActions fields * Zapier integration as coming soon * Update FormCleaner * set default settings for confirmation integration * WIP * Finish validation for all integrations * Updated purify, added integration formatData * Fix testcase * Ran pint; working on integration errors * Handle integration events * command for Delete Old Integration Events * Display Past Events in Modal * on Integration event create with status error send email to form creator * Polish styling * Minor improvements * Finish badge and integration status * Fix tests and add an integration event test * Lint --------- Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
34
app/Console/Commands/CleanIntegrationEvents.php
Normal file
34
app/Console/Commands/CleanIntegrationEvents.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Integration\FormIntegrationsEvent;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class CleanIntegrationEvents extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'forms:integration-events-cleanup';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Delete Old Integration Events';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$response = FormIntegrationsEvent::where('created_at', '<', now()->subDays(14))->delete();
|
||||
$this->line($response . ' Events Deleted');
|
||||
}
|
||||
}
|
||||
107
app/Console/Commands/IntegrationMigration.php
Normal file
107
app/Console/Commands/IntegrationMigration.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Forms\Form;
|
||||
use App\Models\Integration\FormIntegration;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class IntegrationMigration extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'forms:integration-migration';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'One Time Only -- Refactor integration';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Form::chunk(
|
||||
100,
|
||||
function ($forms) {
|
||||
foreach ($forms as $form) {
|
||||
$this->line('Process For Form: ' . $form->id . ' - ' . $form->slug);
|
||||
|
||||
// Email
|
||||
if ($form->notifies && $form->notification_emails) {
|
||||
$this->createFormIntegration($form, 'email', [
|
||||
'notification_reply_to' => $form->notification_settings->notification_reply_to,
|
||||
'notification_emails' => $form->notification_emails
|
||||
]);
|
||||
}
|
||||
|
||||
// Submission Confirmation
|
||||
if ($form->send_submission_confirmation) {
|
||||
$this->createFormIntegration($form, 'submission_confirmation', [
|
||||
'confirmation_reply_to' => $form->notification_settings->confirmation_reply_to,
|
||||
'notification_sender' => $form->notification_sender,
|
||||
'notification_subject' => $form->notification_subject,
|
||||
'notification_body' => $form->notification_body,
|
||||
'notifications_include_submission' => $form->notifications_include_submission,
|
||||
]);
|
||||
}
|
||||
|
||||
// Slack
|
||||
if ($form->slack_webhook_url) {
|
||||
$slackData = $form->notification_settings->slack;
|
||||
$this->createFormIntegration($form, 'slack', [
|
||||
'slack_webhook_url' => $form->slack_webhook_url,
|
||||
'include_submission_data' => $slackData->include_submission_data ?? true,
|
||||
'link_open_form' => $slackData->link_open_form ?? true,
|
||||
'link_edit_form' => $slackData->link_edit_form ?? true,
|
||||
'views_submissions_count' => $slackData->views_submissions_count ?? true,
|
||||
'link_edit_submission' => $slackData->link_edit_submission ?? true
|
||||
]);
|
||||
}
|
||||
|
||||
// Discord
|
||||
if ($form->discord_webhook_url) {
|
||||
$discordData = $form->notification_settings->discord;
|
||||
$this->createFormIntegration($form, 'discord', [
|
||||
'discord_webhook_url' => $form->discord_webhook_url,
|
||||
'include_submission_data' => $discordData->include_submission_data ?? true,
|
||||
'link_open_form' => $discordData->link_open_form ?? true,
|
||||
'link_edit_form' => $discordData->link_edit_form ?? true,
|
||||
'views_submissions_count' => $discordData->views_submissions_count ?? true,
|
||||
'link_edit_submission' => $discordData->link_edit_submission ?? true
|
||||
]);
|
||||
}
|
||||
|
||||
// Webhook
|
||||
if ($form->webhook_url) {
|
||||
$this->createFormIntegration($form, 'webhook', [
|
||||
'webhook_url' => $form->webhook_url
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
$this->line('Migration Done');
|
||||
}
|
||||
|
||||
private function createFormIntegration(Form $form, $integration_id, $data = [])
|
||||
{
|
||||
$this->line('Form Integration Create: ' . $integration_id);
|
||||
return FormIntegration::create([
|
||||
'form_id' => $form->id,
|
||||
'status' => FormIntegration::STATUS_ACTIVE,
|
||||
'integration_id' => $integration_id,
|
||||
'data' => $data,
|
||||
'logic' => []
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ class Kernel extends ConsoleKernel
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule->command('forms:database-cleanup')->hourly();
|
||||
$schedule->command('forms:integration-events-cleanup')->daily();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,7 +34,7 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
$this->load(__DIR__ . '/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user