From 2e0189107435babb6adf107045bcbfc3b50ef6c6 Mon Sep 17 00:00:00 2001 From: DaneEveritt Date: Sat, 9 Jul 2022 17:53:07 -0400 Subject: [PATCH] Account for natural event naming --- .../Remote/ActivityProcessingController.php | 28 ++----------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/app/Http/Controllers/Api/Remote/ActivityProcessingController.php b/app/Http/Controllers/Api/Remote/ActivityProcessingController.php index 30d7fa4e5..0f0447d2a 100644 --- a/app/Http/Controllers/Api/Remote/ActivityProcessingController.php +++ b/app/Http/Controllers/Api/Remote/ActivityProcessingController.php @@ -4,6 +4,7 @@ namespace Pterodactyl\Http\Controllers\Api\Remote; use Exception; use Carbon\Carbon; +use Illuminate\Support\Str; use Pterodactyl\Models\User; use Webmozart\Assert\Assert; use Pterodactyl\Models\Server; @@ -31,7 +32,7 @@ class ActivityProcessingController extends Controller foreach ($request->input('data') as $datum) { /** @var \Pterodactyl\Models\Server|null $server */ $server = $servers->get($datum['server']); - if (is_null($server) || is_null($event = $this->event($datum['event']))) { + if (is_null($server) || !Str::startsWith($datum['event'], 'server:')) { continue; } @@ -53,7 +54,7 @@ class ActivityProcessingController extends Controller $log = [ 'ip' => empty($datum['ip']) ? '127.0.0.1' : $datum['ip'], - 'event' => $event, + 'event' => $datum['event'], 'properties' => json_encode($datum['metadata'] ?? []), // We have to change the time to the current timezone due to the way Laravel is handling // the date casting internally. If we just leave it in UTC it ends up getting double-cast @@ -89,27 +90,4 @@ class ActivityProcessingController extends Controller ActivityLogSubject::insert($batch); } } - - /** - * Takes an event from Wings and converts it into the expected event type on - * the Panel. If no matching event type can be deduced, null is returned and - * the event won't be logged. - */ - protected function event(string $input): ?string - { - switch ($input) { - case 'console_command': - return 'server:console.command'; - case 'power_start': - return 'server:power.start'; - case 'power_stop': - return 'server:power.stop'; - case 'power_restart': - return 'server:power.restart'; - case 'power_kill': - return 'server:power.kill'; - default: - return null; - } - } }