From 8cd3b381cf9d1ccb4ba250c6fe3e42c01c89314e Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 11 Mar 2025 19:23:31 -0400 Subject: [PATCH] Refactor AddressBookGetContact to streamline peer address validation and response handling https://github.com/nosial/Socialbox-PHP/issues/33 --- .../AddressBook/AddressBookGetContact.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookGetContact.php b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookGetContact.php index 5443d29..d73c9cd 100644 --- a/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookGetContact.php +++ b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookGetContact.php @@ -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) {