Skip to content

Commit

Permalink
update supervisor
Browse files Browse the repository at this point in the history
  • Loading branch information
gwleuverink committed Apr 16, 2024
1 parent c89dd1f commit b896551
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/Livewire/Concerns/SmtpSupervisor.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
use App\Services\Smtp\Server;
use App\Events\MessageReceived;
use Livewire\Attributes\Renderless;
use Native\Laravel\Facades\Notification;
use ZBateson\MailMimeParser\Header\HeaderConsts;

trait SmtpSupervisor
{
const PORT = 2525;
const NOTIFICATION_TITLE = "You've got Phost!";

/**
* Called with wire:poll to keep the server alive.
Expand All @@ -26,9 +29,13 @@ function () {
Server::new(self::PORT)
->onMessageReceived(function ($content) {

MessageReceived::dispatch(
Message::fromContent($content)
);
$message = Message::fromContent($content);

Notification::title(self::NOTIFICATION_TITLE)
->message($message->parsed->getHeaderValue(HeaderConsts::SUBJECT))
->show();

MessageReceived::dispatch($message);

})->serve();
},
Expand Down

0 comments on commit b896551

Please sign in to comment.