activeTransfer($uuid); $node = RemoteRequestNode::get($request); throw_if(! $node->is($transfer->newNode) && ! $node->is($transfer->oldNode), HttpForbiddenException::class, 'Requesting node does not have permission to access this server.'); $transfers->fail($transfer); return new JsonResponse([], Response::HTTP_NO_CONTENT); } /** * The daemon notifies us about a transfer success. Only the new node may report it. * * @throws Throwable */ public function success(Request $request, CompletesTransfers $transfers, string $uuid): JsonResponse { $transfer = $this->activeTransfer($uuid); $node = RemoteRequestNode::get($request); throw_unless($node->is($transfer->newNode), HttpForbiddenException::class, 'Requesting node does not have permission to access this server.'); $transfers->complete($transfer); return new JsonResponse([], Response::HTTP_NO_CONTENT); } private function activeTransfer(string $uuid): ServerTransfer { $server = Server::query()->with('node')->whereUuidOrShort($uuid)->firstOrFail(); return $server->transfer ?? throw new ConflictHttpException('Server is not being transferred.'); } }