where('uuid', $backup) ->firstOrFail(); // Check that the backup is "owned" by the node making the request. This avoids other nodes // from messing with backups that they don't own. $server = $model->server; throw_if($server->node_id !== $node->id, HttpForbiddenException::class, 'Requesting node does not have permission to access this server.'); throw_if($model->is_successful, BadRequestHttpException::class, 'Cannot update the status of a backup that is already marked as completed.'); $completeBackup->complete($model, $request->actionInput()); return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT); } /** * Resets the server status to null after a restore attempt. * * @throws Throwable */ public function restore(ReportBackupRestoreRequest $request, RestoresBackupStatuses $restoreStatus, string $backup): JsonResponse { $restoreStatus->restoreStatus($backup, RemoteRequestNode::get($request), $request->safe()->boolean('successful')); return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT); } }