diff --git a/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookContactExists.php b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookContactExists.php new file mode 100644 index 0000000..c592341 --- /dev/null +++ b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookContactExists.php @@ -0,0 +1,51 @@ +containsParameter('peer')) + { + return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, 'Missing required peer parameter'); + } + + try + { + $address = PeerAddress::fromAddress($rpcRequest->getParameter('peer')); + } + catch(InvalidArgumentException $e) + { + throw new StandardException('Invalid peer address', StandardError::RPC_INVALID_ARGUMENTS, $e); + } + + try + { + $peer = $request->getPeer(); + return $rpcRequest->produceResponse(ContactManager::isContact($peer, $address)); + } + catch (DatabaseOperationException $e) + { + throw new StandardException('Failed to check if the contact exists', StandardError::INTERNAL_SERVER_ERROR, $e); + } + } + } \ No newline at end of file