Move notification email of server created into the event listener
This commit is contained in:
parent
b8271cf8f6
commit
96e50506a1
3 changed files with 20 additions and 18 deletions
|
@ -26,9 +26,11 @@ namespace Pterodactyl\Observers;
|
||||||
|
|
||||||
use Carbon;
|
use Carbon;
|
||||||
use Pterodactyl\Events;
|
use Pterodactyl\Events;
|
||||||
|
use Pterodactyl\Models\User;
|
||||||
use Pterodactyl\Models\Server;
|
use Pterodactyl\Models\Server;
|
||||||
use Pterodactyl\Jobs\DeleteServer;
|
use Pterodactyl\Jobs\DeleteServer;
|
||||||
use Pterodactyl\Jobs\SuspendServer;
|
use Pterodactyl\Jobs\SuspendServer;
|
||||||
|
use Pterodactyl\Notifications\ServerCreated;
|
||||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
|
|
||||||
class ServerObserver
|
class ServerObserver
|
||||||
|
@ -55,6 +57,17 @@ class ServerObserver
|
||||||
public function created(Server $server)
|
public function created(Server $server)
|
||||||
{
|
{
|
||||||
event(new Events\Server\Created($server));
|
event(new Events\Server\Created($server));
|
||||||
|
|
||||||
|
// Queue Notification Email
|
||||||
|
$user = User::findOrFail($server->owner);
|
||||||
|
$user->notify((new ServerCreated([
|
||||||
|
'name' => $server->name,
|
||||||
|
'memory' => $server->memory,
|
||||||
|
'node' => $node->name,
|
||||||
|
'service' => $service->name,
|
||||||
|
'option' => $option->name,
|
||||||
|
'uuidShort' => $server->uuidShort,
|
||||||
|
])));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,7 +32,6 @@ use Pterodactyl\Models;
|
||||||
use Pterodactyl\Services\UuidService;
|
use Pterodactyl\Services\UuidService;
|
||||||
use Pterodactyl\Services\DeploymentService;
|
use Pterodactyl\Services\DeploymentService;
|
||||||
use Pterodactyl\Exceptions\DisplayException;
|
use Pterodactyl\Exceptions\DisplayException;
|
||||||
use Pterodactyl\Notifications\ServerCreated;
|
|
||||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||||
|
|
||||||
class ServerRepository
|
class ServerRepository
|
||||||
|
@ -300,16 +299,6 @@ class ServerRepository
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Queue Notification Email
|
|
||||||
$user->notify((new ServerCreated([
|
|
||||||
'name' => $server->name,
|
|
||||||
'memory' => $server->memory,
|
|
||||||
'node' => $node->name,
|
|
||||||
'service' => $service->name,
|
|
||||||
'option' => $option->name,
|
|
||||||
'uuidShort' => $server->uuidShort,
|
|
||||||
])));
|
|
||||||
|
|
||||||
$client = Models\Node::guzzleRequest($node->id);
|
$client = Models\Node::guzzleRequest($node->id);
|
||||||
$client->request('POST', '/servers', [
|
$client->request('POST', '/servers', [
|
||||||
'headers' => [
|
'headers' => [
|
||||||
|
|
Loading…
Reference in a new issue