webhooks & slack changes (#90)
This commit is contained in:
parent
d6930d0dc2
commit
eb3a11c992
|
@ -45,7 +45,7 @@ class StoreFormSubmissionJob implements ShouldQueue
|
|||
|
||||
$this->storeSubmission($formData);
|
||||
|
||||
$formData["submission_id"] = $this->submissionData['submission_id'] ?? null;
|
||||
$formData["submission_id"] = $this->submissionId;
|
||||
FormSubmitted::dispatch($this->form, $formData);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ use Illuminate\Queue\InteractsWithQueue;
|
|||
use Illuminate\Support\Facades\Notification;
|
||||
use Spatie\WebhookServer\WebhookCall;
|
||||
use App\Service\Forms\FormSubmissionFormatter;
|
||||
use Vinkla\Hashids\Facades\Hashids;
|
||||
|
||||
class NotifyFormSubmission implements ShouldQueue
|
||||
{
|
||||
|
@ -57,6 +58,15 @@ class NotifyFormSubmission implements ShouldQueue
|
|||
|
||||
$formURL = url("forms/".$event->form->slug);
|
||||
$editFormURL = url("forms/".$event->form->slug."/show");
|
||||
$submissionId = Hashids::encode($event->data['submission_id']);
|
||||
$externalLinks = [
|
||||
'*<'.$formURL.'|🔗 Open Form>*',
|
||||
'*<'.$editFormURL.'|✍️ Edit Form>*'
|
||||
];
|
||||
if($event->form->editable_submissions){
|
||||
$externalLinks[] = '*<'.$event->form->share_url.'?submission_id='.$submissionId.'|✍️ Edit Submission>*';
|
||||
}
|
||||
|
||||
$finalSlackPostData = [
|
||||
'blocks' => [
|
||||
[
|
||||
|
@ -77,7 +87,7 @@ class NotifyFormSubmission implements ShouldQueue
|
|||
'type' => 'section',
|
||||
'text' => [
|
||||
'type' => 'mrkdwn',
|
||||
'text' => '*<'.$formURL.'|🔗 Open Form>* *<'.$editFormURL.'|✍️ Edit Form>*',
|
||||
'text' => implode(' ', $externalLinks),
|
||||
]
|
||||
],
|
||||
]
|
||||
|
|
|
@ -8,7 +8,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
|||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Spatie\WebhookServer\WebhookCall;
|
||||
use App\Service\Forms\FormSubmissionFormatter;
|
||||
|
||||
use Vinkla\Hashids\Facades\Hashids;
|
||||
class PostFormDataToWebhook implements ShouldQueue
|
||||
{
|
||||
use InteractsWithQueue;
|
||||
|
@ -62,11 +62,16 @@ class PostFormDataToWebhook implements ShouldQueue
|
|||
$formattedData[$field['name']] = $field['value'];
|
||||
}
|
||||
|
||||
return [
|
||||
$submissionId = Hashids::encode($event->data['submission_id']);
|
||||
$data = [
|
||||
'form_title' => $event->form->title,
|
||||
'form_slug' => $event->form->slug,
|
||||
'submission' => $formattedData
|
||||
];
|
||||
if($event->form->editable_submissions){
|
||||
$data['edit_link'] = $event->form->share_url.'?submission_id='.$submissionId;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue