1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-22 09:02:28 +01:00

api(server): log activity when server description is changed

This commit is contained in:
Matthew Penner 2022-11-21 13:41:26 -07:00
parent 634c9353e3
commit 039ad4abf0
No known key found for this signature in database
2 changed files with 14 additions and 6 deletions

View File

@ -34,14 +34,22 @@ class SettingsController extends ClientApiController
*/
public function rename(RenameServerRequest $request, Server $server): JsonResponse
{
$name = $request->input('name');
$description = $request->input('description') ?? '';
$this->repository->update($server->id, [
'name' => $request->input('name'),
'description' => $request->input('description') ?? '',
'name' => $name,
'description' => $description,
]);
if ($server->name !== $request->input('name')) {
if ($server->name !== $name) {
Activity::event('server:settings.rename')
->property(['old' => $server->name, 'new' => $request->input('name')])
->property(['old' => $server->name, 'new' => $name])
->log();
}
if ($server->description !== $description) {
Activity::event('server:settings.description')
->property(['old' => $server->description, 'new' => $description])
->log();
}

View File

@ -99,7 +99,7 @@ class ActivityLogService
}
/**
* Sets a custom property on the activty log instance.
* Sets a custom property on the activity log instance.
*
* @param string|array $key
* @param mixed $value
@ -115,7 +115,7 @@ class ActivityLogService
}
/**
* Attachs the instance request metadata to the activity log event.
* Attaches the instance request metadata to the activity log event.
*/
public function withRequestMetadata(): self
{