Handling ICAL import

This commit is contained in:
2026-04-25 16:50:32 +02:00
parent 6f8be58943
commit 1ee6b9968f
22 changed files with 510 additions and 19 deletions

View File

@@ -2,6 +2,12 @@
namespace App\Mail\ParticipantParticipationMails;
use App\Domains\Event\Actions\GenerateIcal\GenerateIcalCommand;
use App\Domains\Event\Actions\GenerateIcal\GenerateIcalRequest;
use App\Domains\Event\Actions\GenerateIcal\GenerateIcalResponse;
use App\Domains\Event\Actions\GenerateIcalForDeadline\GenerateIcalForDeadlineCommand;
use App\Domains\Event\Actions\GenerateIcalForDeadline\GenerateIcalForDeadlineRequest;
use App\Domains\Event\Actions\GenerateIcalForDeadline\GenerateIcalForDeadlineResponse;
use App\Models\EventParticipant;
use Illuminate\Bus\Queueable;
use Illuminate\Http\Request;
@@ -15,6 +21,10 @@ class EventSignUpSuccessfullMail extends Mailable
{
use Queueable, SerializesModels;
private ?GenerateIcalResponse $participationIcal = null;
private ?GenerateIcalForDeadlineResponse $deadlineIcal = null;
/**
* Create a new message instance.
*/
@@ -60,6 +70,10 @@ class EventSignUpSuccessfullMail extends Mailable
);
$girocodeBinary = (string)$girocodeProvider->create();
$participationIcal = $this->getParticipationIcal();
$deadlineIcal = $this->getDeadlineIcal();
return new Content(
view: 'emails.events.signup_complete',
with: [
@@ -76,19 +90,57 @@ class EventSignUpSuccessfullMail extends Mailable
'accountIban' => $event['accountIban'],
'paymentPurpose' => $participant['payment_purpose'],
'girocodeBinary' => $girocodeBinary,
'efzStatus' => $participant['efz_status']
'efzStatus' => $participant['efz_status'],
'participationIcalFilename' => $participationIcal->filename,
'deadlineIcalFilename' => $deadlineIcal->filename,
],
);
}
/**
* Get the attachments for the message.
*
* @return array<int, Attachment>
*/
public function attachments(): array
{
return [];
$attachments = [
Attachment::fromData(
fn () => $this->getParticipationIcal()->icalContent,
$this->getParticipationIcal()->filename
)->withMime('text/calendar'),
];
$participant = $this->participant->toResource()->toArray(new Request());
if ($participant['needs_payment']) {
/*$attachments[] = [
Attachment::fromData(
fn () => $this->getDeadlineIcal()->icalContent,
$this->getDeadlineIcal()->filename
)->withMime('text/calendar'),
];*/
}
return $attachments;
}
private function getDeadlineIcal(): GenerateIcalForDeadlineResponse
{
if ($this->deadlineIcal === null) {
$this->deadlineIcal = (new GenerateIcalForDeadlineCommand(
new GenerateIcalForDeadlineRequest($this->participant->event()->first())
))->execute();
}
return $this->deadlineIcal;
}
private function getParticipationIcal(): GenerateIcalResponse
{
if ($this->participationIcal === null) {
$this->participationIcal = (new GenerateIcalCommand(
new GenerateIcalRequest($this->participant)
))->execute();
}
return $this->participationIcal;
}
}