Separated laravel app to its own folder (#540)
This commit is contained in:
38
api/app/Mail/Forms/FormCreationConfirmationMail.php
Normal file
38
api/app/Mail/Forms/FormCreationConfirmationMail.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail\Forms;
|
||||
|
||||
use App\Mail\OpenFormMail;
|
||||
use App\Models\Forms\Form;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class FormCreationConfirmationMail extends OpenFormMail implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(public Form $form)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this
|
||||
->markdown('mail.form.created', [
|
||||
'form' => $this->form,
|
||||
])->subject('Your form was created!');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail\Forms;
|
||||
|
||||
use App\Mail\OpenFormMail;
|
||||
use App\Models\Integration\FormIntegration;
|
||||
use App\Models\Integration\FormIntegrationsEvent;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class FormIntegrationsEventCreationConfirmationMail extends OpenFormMail implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
public $formIntegration;
|
||||
public $form;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(public FormIntegrationsEvent $formIntegrationsEvent)
|
||||
{
|
||||
$this->formIntegration = $formIntegrationsEvent->integration;
|
||||
$this->form = $this->formIntegration->form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$integration = FormIntegration::getIntegration($this->formIntegration->integration_id);
|
||||
return $this
|
||||
->markdown('mail.form.integrations-event-created', [
|
||||
'form' => $this->form,
|
||||
'integration_name' => $integration['name'] ?? '',
|
||||
'error' => json_encode($this->formIntegrationsEvent->data)
|
||||
])->subject("Integration issue with your form: '" . $this->form->title . "'");
|
||||
}
|
||||
}
|
||||
71
api/app/Mail/Forms/SubmissionConfirmationMail.php
Normal file
71
api/app/Mail/Forms/SubmissionConfirmationMail.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail\Forms;
|
||||
|
||||
use App\Events\Forms\FormSubmitted;
|
||||
use App\Mail\OpenFormMail;
|
||||
use App\Service\Forms\FormSubmissionFormatter;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Str;
|
||||
use Vinkla\Hashids\Facades\Hashids;
|
||||
|
||||
class SubmissionConfirmationMail extends OpenFormMail implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(private FormSubmitted $event, private $integrationData)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$form = $this->event->form;
|
||||
|
||||
$formatter = (new FormSubmissionFormatter($form, $this->event->data))
|
||||
->createLinks()
|
||||
->outputStringsOnly()
|
||||
->useSignedUrlForFiles();
|
||||
|
||||
return $this
|
||||
->replyTo($this->getReplyToEmail($form->creator->email))
|
||||
->from($this->getFromEmail(), $this->integrationData->notification_sender)
|
||||
->subject($this->integrationData->notification_subject)
|
||||
->markdown('mail.form.confirmation-submission-notification', [
|
||||
'fields' => $formatter->getFieldsWithValue(),
|
||||
'form' => $form,
|
||||
'integrationData' => $this->integrationData,
|
||||
'noBranding' => $form->no_branding,
|
||||
'submission_id' => (isset($this->event->data['submission_id']) && $this->event->data['submission_id']) ? Hashids::encode($this->event->data['submission_id']) : null,
|
||||
]);
|
||||
}
|
||||
|
||||
private function getFromEmail()
|
||||
{
|
||||
$originalFromAddress = Str::of(config('mail.from.address'))->explode('@');
|
||||
|
||||
return $originalFromAddress->first() . '+' . time() . '@' . $originalFromAddress->last();
|
||||
}
|
||||
|
||||
private function getReplyToEmail($default)
|
||||
{
|
||||
$replyTo = $this->integrationData->confirmation_reply_to ?? null;
|
||||
|
||||
if ($replyTo && filter_var($replyTo, FILTER_VALIDATE_EMAIL)) {
|
||||
return $replyTo;
|
||||
}
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
13
api/app/Mail/OpenFormMail.php
Normal file
13
api/app/Mail/OpenFormMail.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
abstract class OpenFormMail extends Mailable
|
||||
{
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
}
|
||||
41
api/app/Mail/UserInvitationEmail.php
Normal file
41
api/app/Mail/UserInvitationEmail.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\UserInvite;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class UserInvitationEmail extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param string $workspaceName
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(public UserInvite $invite)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$workspaceName = $this->invite->workspace->name;
|
||||
return $this
|
||||
->markdown('mail.user.invitation', [
|
||||
'workspaceName' => $workspaceName,
|
||||
'inviteLink' => $this->invite->getLink(),
|
||||
])->subject('You are invited to join ' . $workspaceName . ' on OpnForm');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user