Refactor AddressBookGetContact to streamline peer address validation and response handling
https://github.com/nosial/Socialbox-PHP/issues/33
This commit is contained in:
parent
1c48fcd35e
commit
8cd3b381cf
1 changed files with 2 additions and 10 deletions
|
@ -29,24 +29,16 @@
|
||||||
throw new MissingRpcArgumentException('peer');
|
throw new MissingRpcArgumentException('peer');
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$address = PeerAddress::fromAddress($rpcRequest->getParameter('peer'));
|
$address = PeerAddress::fromAddress($rpcRequest->getParameter('peer'));
|
||||||
}
|
|
||||||
catch(InvalidArgumentException $e)
|
|
||||||
{
|
|
||||||
throw new InvalidRpcArgumentException('peer', $e);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(!ContactManager::isContact($request->getPeer(), $address))
|
if(!ContactManager::isContact($request->getPeer(), $address))
|
||||||
{
|
{
|
||||||
// Return empty response if the contact does not exist
|
|
||||||
return $rpcRequest->produceResponse();
|
return $rpcRequest->produceResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
$rpcRequest->produceResponse(ContactManager::getStandardContact($request->getPeer(), $address));
|
return $rpcRequest->produceResponse(ContactManager::getStandardContact($request->getPeer(), $address));
|
||||||
}
|
}
|
||||||
catch(DatabaseOperationException $e)
|
catch(DatabaseOperationException $e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue