containsParameter('peer')) { return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, "Missing 'peer' parameter"); } // Parse the peer address try { $peerAddress = PeerAddress::fromAddress($rpcRequest->getParameter('peer')); } catch(InvalidArgumentException $e) { throw new StandardException('Peer Address Error: ' . $e->getMessage(), StandardError::RPC_INVALID_ARGUMENTS, $e); } // Check if host is making the request & the identifier is not empty $identifyAs = null; if($request->getPeer()->getUsername() == ReservedUsernames::HOST && $request->getIdentifyAs() != null) { $identifyAs = $request->getIdentifyAs(); } // Resolve the peer using the server's peer resolver, this will resolve both internal peers and external peers try { return $rpcRequest->produceResponse(Socialbox::resolvePeer($peerAddress, $identifyAs)); } catch(Exception $e) { throw new StandardException(sprintf('There was an error while trying to resolve the peer %s: %s', $peerAddress, $e->getMessage()), StandardError::RESOLUTION_FAILED, $e); } } }