Skip to content

Commit

Permalink
Fixed ForwardEmail attachments bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hrsa committed May 12, 2024
1 parent 5818fe1 commit 6f777ff
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
2 changes: 0 additions & 2 deletions app/Http/Controllers/Auth/RegisteredUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Rules;
use Inertia\Inertia;
use Inertia\Response;

Expand Down
15 changes: 11 additions & 4 deletions app/Mail/ForwardEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace App\Mail;

use App\Exceptions\NoSummaryException;
use App\Models\IcsEvent;
use BeyondCode\Mailbox\InboundEmail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
Expand All @@ -23,7 +21,7 @@ public function __construct(public InboundEmail $inboundEmail)
public function envelope(): Envelope
{
return new Envelope(
subject: "FROM: " . $this->inboundEmail->fromName() . " (" . $this->inboundEmail->from() . ") - " . $this->inboundEmail->subject(),
subject: 'FROM: ' . $this->inboundEmail->fromName() . ' (' . $this->inboundEmail->from() . ') - ' . $this->inboundEmail->subject(),
);
}

Expand All @@ -36,6 +34,15 @@ public function content(): Content

public function attachments(): array
{
return $this->inboundEmail->attachments();
$attachments = [];

foreach ($this->inboundEmail->attachments() as $attachment) {
if ($attachment->getFilename()) {
$attachments[] = Attachment::fromData(fn () => $attachment->getContent(), $attachment->getFilename())
->withMime($attachment->getContentType());
}
}

return $attachments;
}
}
2 changes: 1 addition & 1 deletion app/Mail/IcsValid.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function attachments(): array
{
return [
Attachment::fromData(fn () => $this->icsEvent->ics, $this->icsEvent->getSummary() . '.ics')
->withMime('text/calendar'),
->withMime('text/calendar'),
];
}
}
8 changes: 4 additions & 4 deletions app/Providers/MailProcessingServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public function register(): void

public function boot(MailProcessingService $service): void
{
Mailbox::to('[email protected]', fn(InboundEmail $inboundEmail) => $service->process($inboundEmail));
Mailbox::to('[email protected]', fn(InboundEmail $inboundEmail) => $service->process($inboundEmail));
Mailbox::to('[email protected]', fn(InboundEmail $inboundEmail) => $service->forwardToAdmin($inboundEmail));
Mailbox::to('[email protected]', fn(InboundEmail $inboundEmail) => $service->forwardToAdmin($inboundEmail));
Mailbox::to('[email protected]', fn (InboundEmail $inboundEmail) => $service->process($inboundEmail));
Mailbox::to('[email protected]', fn (InboundEmail $inboundEmail) => $service->process($inboundEmail));
Mailbox::to('[email protected]', fn (InboundEmail $inboundEmail) => $service->forwardToAdmin($inboundEmail));
Mailbox::to('[email protected]', fn (InboundEmail $inboundEmail) => $service->forwardToAdmin($inboundEmail));
}
}
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
|
*/

'debug' => (bool)env('APP_DEBUG', false),
'debug' => (bool) env('APP_DEBUG', false),

/*
|--------------------------------------------------------------------------
Expand Down

0 comments on commit 6f777ff

Please sign in to comment.