Account for natural event naming
This commit is contained in:
parent
1eee55b27c
commit
2e01891074
|
@ -4,6 +4,7 @@ namespace Pterodactyl\Http\Controllers\Api\Remote;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Pterodactyl\Models\User;
|
use Pterodactyl\Models\User;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
use Pterodactyl\Models\Server;
|
use Pterodactyl\Models\Server;
|
||||||
|
@ -31,7 +32,7 @@ class ActivityProcessingController extends Controller
|
||||||
foreach ($request->input('data') as $datum) {
|
foreach ($request->input('data') as $datum) {
|
||||||
/** @var \Pterodactyl\Models\Server|null $server */
|
/** @var \Pterodactyl\Models\Server|null $server */
|
||||||
$server = $servers->get($datum['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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +54,7 @@ class ActivityProcessingController extends Controller
|
||||||
|
|
||||||
$log = [
|
$log = [
|
||||||
'ip' => empty($datum['ip']) ? '127.0.0.1' : $datum['ip'],
|
'ip' => empty($datum['ip']) ? '127.0.0.1' : $datum['ip'],
|
||||||
'event' => $event,
|
'event' => $datum['event'],
|
||||||
'properties' => json_encode($datum['metadata'] ?? []),
|
'properties' => json_encode($datum['metadata'] ?? []),
|
||||||
// We have to change the time to the current timezone due to the way Laravel is handling
|
// 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
|
// 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);
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue