Refactor AddressBookGetContact to streamline peer address validation and response handling

https://github.com/nosial/Socialbox-PHP/issues/33
This commit is contained in:
netkas 2025-03-11 19:23:31 -04:00
parent 1c48fcd35e
commit 8cd3b381cf
Signed by: netkas
GPG key ID: 4D8629441B76E4CC

View file

@ -29,24 +29,16 @@
throw new MissingRpcArgumentException('peer');
}
try
{
$address = PeerAddress::fromAddress($rpcRequest->getParameter('peer'));
}
catch(InvalidArgumentException $e)
{
throw new InvalidRpcArgumentException('peer', $e);
}
$address = PeerAddress::fromAddress($rpcRequest->getParameter('peer'));
try
{
if(!ContactManager::isContact($request->getPeer(), $address))
{
// Return empty response if the contact does not exist
return $rpcRequest->produceResponse();
}
$rpcRequest->produceResponse(ContactManager::getStandardContact($request->getPeer(), $address));
return $rpcRequest->produceResponse(ContactManager::getStandardContact($request->getPeer(), $address));
}
catch(DatabaseOperationException $e)
{