Skip to content

Commit

Permalink
feature: Detailed extension update logs
Browse files Browse the repository at this point in the history
  • Loading branch information
dogukanoksuz committed Jan 11, 2024
1 parent fe4499f commit d6959c5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 8 additions & 3 deletions app/Http/Controllers/API/Settings/ExtensionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function upload()
(string) request()->file('extension')->path()
);
}
[$error, $new] = $this->setupNewExtension($zipFile, $verify);
[$error, $new, $old] = $this->setupNewExtension($zipFile, $verify);

if ($error) {
return $error;
Expand All @@ -115,7 +115,11 @@ public function upload()
'extension_id' => $new->id,
'extension_name' => $new->display_name ?? $new->name,
],
"EXTENSION_UPLOAD"
'EXTENSION_UPLOAD',
[
'old' => $old,
'new' => $new,
]
);

return response()->json([
Expand Down Expand Up @@ -340,6 +344,7 @@ private function setupNewExtension($zipFile, $verify = false)

// Check If Extension Already Exists.
$extension = Extension::where('name', $json['name'])->first();
$old = $extension->toArray();

if ($extension) {
if ($extension->version == $json['version']) {
Expand Down Expand Up @@ -393,6 +398,6 @@ private function setupNewExtension($zipFile, $verify = false)
]);
$system->fixExtensionPermissions($new->id, $new->name);

return [null, $new];
return [null, $new, $old];
}
}
5 changes: 4 additions & 1 deletion app/Models/AuditLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public static function write(
string $type,
string $action,
array $details,
string $message = ""
string $message = "",
array $extra = []
) {
$request = request()->all();
unset($request['password']);
Expand All @@ -54,6 +55,8 @@ public static function write(
}
}

$request = array_merge($request, $extra);

return self::create([
'user_id' => auth('api')->user()->id,
'ip_address' => request()->ip(),
Expand Down

0 comments on commit d6959c5

Please sign in to comment.