Skip to content

Commit 039ad4a

Browse files
committed
api(server): log activity when server description is changed
1 parent 634c935 commit 039ad4a

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,22 @@ public function __construct(
3434
*/
3535
public function rename(RenameServerRequest $request, Server $server): JsonResponse
3636
{
37+
$name = $request->input('name');
38+
$description = $request->input('description') ?? '';
3739
$this->repository->update($server->id, [
38-
'name' => $request->input('name'),
39-
'description' => $request->input('description') ?? '',
40+
'name' => $name,
41+
'description' => $description,
4042
]);
4143

42-
if ($server->name !== $request->input('name')) {
44+
if ($server->name !== $name) {
4345
Activity::event('server:settings.rename')
44-
->property(['old' => $server->name, 'new' => $request->input('name')])
46+
->property(['old' => $server->name, 'new' => $name])
47+
->log();
48+
}
49+
50+
if ($server->description !== $description) {
51+
Activity::event('server:settings.description')
52+
->property(['old' => $server->description, 'new' => $description])
4553
->log();
4654
}
4755

app/Services/Activity/ActivityLogService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function actor(Model $actor): self
9999
}
100100

101101
/**
102-
* Sets a custom property on the activty log instance.
102+
* Sets a custom property on the activity log instance.
103103
*
104104
* @param string|array $key
105105
* @param mixed $value
@@ -115,7 +115,7 @@ public function property($key, $value = null): self
115115
}
116116

117117
/**
118-
* Attachs the instance request metadata to the activity log event.
118+
* Attaches the instance request metadata to the activity log event.
119119
*/
120120
public function withRequestMetadata(): self
121121
{

0 commit comments

Comments
 (0)