Audit when a backup is successful or fails
This commit is contained in:
parent
291c65275a
commit
bfc6f34c50
1 changed files with 22 additions and 14 deletions
|
@ -4,6 +4,7 @@ namespace Pterodactyl\Http\Controllers\Api\Remote\Backups;
|
|||
|
||||
use Carbon\CarbonImmutable;
|
||||
use Pterodactyl\Models\Backup;
|
||||
use Pterodactyl\Models\AuditLog;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use League\Flysystem\AwsS3v3\AwsS3Adapter;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
|
@ -44,7 +45,7 @@ class BackupStatusController extends Controller
|
|||
* @param string $backup
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function __invoke(ReportBackupCompleteRequest $request, string $backup)
|
||||
{
|
||||
|
@ -57,8 +58,14 @@ class BackupStatusController extends Controller
|
|||
);
|
||||
}
|
||||
|
||||
$successful = $request->input('successful') ? true : false;
|
||||
$action = $request->input('successful')
|
||||
? AuditLog::ACTION_SERVER_BACKUP_COMPELTED
|
||||
: AuditLog::ACTION_SERVER_BACKUP_FAILED;
|
||||
|
||||
$model->server->audit($action, function (AuditLog $audit) use ($model, $request) {
|
||||
$audit->metadata = ['backup_uuid' => $model->uuid];
|
||||
|
||||
$successful = $request->input('successful') ? true : false;
|
||||
$model->fill([
|
||||
'is_successful' => $successful,
|
||||
'checksum' => $successful ? ($request->input('checksum_type') . ':' . $request->input('checksum')) : null,
|
||||
|
@ -72,6 +79,7 @@ class BackupStatusController extends Controller
|
|||
if ($adapter instanceof AwsS3Adapter) {
|
||||
$this->completeMultipartUpload($model, $adapter, $successful);
|
||||
}
|
||||
});
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue