2018-07-01 21:34:40 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Notifications;
|
|
|
|
|
2022-10-14 16:59:20 +00:00
|
|
|
use Pterodactyl\Models\User;
|
2018-07-01 21:34:40 +00:00
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Pterodactyl\Events\Event;
|
2022-10-14 16:59:20 +00:00
|
|
|
use Pterodactyl\Models\Server;
|
2018-07-01 21:34:40 +00:00
|
|
|
use Illuminate\Container\Container;
|
2022-10-14 16:59:20 +00:00
|
|
|
use Pterodactyl\Events\Server\Installed;
|
2018-07-01 21:34:40 +00:00
|
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Pterodactyl\Contracts\Core\ReceivesEvents;
|
|
|
|
use Illuminate\Contracts\Notifications\Dispatcher;
|
|
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
|
|
|
|
|
|
class ServerInstalled extends Notification implements ShouldQueue, ReceivesEvents
|
|
|
|
{
|
|
|
|
use Queueable;
|
|
|
|
|
2022-10-14 16:59:20 +00:00
|
|
|
public Server $server;
|
2018-07-01 21:34:40 +00:00
|
|
|
|
2022-10-14 16:59:20 +00:00
|
|
|
public User $user;
|
2018-07-01 21:34:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle a direct call to this notification from the server installed event. This is configured
|
|
|
|
* in the event service provider.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function handle(Event|Installed $event): void
|
2018-07-01 21:34:40 +00:00
|
|
|
{
|
|
|
|
$event->server->loadMissing('user');
|
|
|
|
|
|
|
|
$this->server = $event->server;
|
|
|
|
$this->user = $event->server->user;
|
|
|
|
|
|
|
|
// Since we are calling this notification directly from an event listener we need to fire off the dispatcher
|
|
|
|
// to send the email now. Don't use send() or you'll end up firing off two different events.
|
|
|
|
Container::getInstance()->make(Dispatcher::class)->sendNow($this->user, $this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the notification's delivery channels.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function via(): array
|
2018-07-01 21:34:40 +00:00
|
|
|
{
|
|
|
|
return ['mail'];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the mail representation of the notification.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function toMail(): MailMessage
|
2018-07-01 21:34:40 +00:00
|
|
|
{
|
2021-01-23 20:33:34 +00:00
|
|
|
return (new MailMessage())
|
2018-07-01 21:34:40 +00:00
|
|
|
->greeting('Hello ' . $this->user->username . '.')
|
|
|
|
->line('Your server has finished installing and is now ready for you to use.')
|
|
|
|
->line('Server Name: ' . $this->server->name)
|
|
|
|
->action('Login and Begin Using', route('index'));
|
|
|
|
}
|
|
|
|
}
|