Skip to content

Commit 4a8c3c4

Browse files
committed
Add activity tracking for console/power actions
1 parent dc90d8b commit 4a8c3c4

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

app/Http/Controllers/Api/Client/Servers/CommandController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Http\Response;
66
use Pterodactyl\Models\Server;
7+
use Pterodactyl\Facades\Activity;
78
use Psr\Http\Message\ResponseInterface;
89
use GuzzleHttp\Exception\BadResponseException;
910
use Symfony\Component\HttpKernel\Exception\HttpException;
@@ -53,6 +54,8 @@ public function index(SendCommandRequest $request, Server $server): Response
5354
throw $exception;
5455
}
5556

57+
Activity::event('server:console.command')->property('command', $request->input('command'))->log();
58+
5659
return $this->returnNoContent();
5760
}
5861
}

app/Http/Controllers/Api/Client/Servers/PowerController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Http\Response;
66
use Pterodactyl\Models\Server;
7+
use Pterodactyl\Facades\Activity;
78
use Pterodactyl\Repositories\Wings\DaemonPowerRepository;
89
use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
910
use Pterodactyl\Http\Requests\Api\Client\Servers\SendPowerRequest;
@@ -27,15 +28,15 @@ public function __construct(DaemonPowerRepository $repository)
2728

2829
/**
2930
* Send a power action to a server.
30-
*
31-
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
3231
*/
3332
public function index(SendPowerRequest $request, Server $server): Response
3433
{
3534
$this->repository->setServer($server)->send(
3635
$request->input('signal')
3736
);
3837

38+
Activity::event(strtolower("server:power.{$request->input('signal')}"))->log();
39+
3940
return $this->returnNoContent();
4041
}
4142
}

resources/lang/en/activity.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@
3737
],
3838
'server' => [
3939
'reinstall' => 'Reinstalled server',
40+
'console' => [
41+
'command' => 'Executed ":command" on the server',
42+
],
43+
'power' => [
44+
'start' => 'Started the server',
45+
'stop' => 'Stopped the server',
46+
'restart' => 'Restarted the server',
47+
'kill' => 'Killed the server process',
48+
],
4049
'backup' => [
4150
'download' => 'Downloaded the :name backup',
4251
'delete' => 'Deleted the :name backup',

0 commit comments

Comments
 (0)