Update addressBookAddContact method to return boolean and adjust response handling
Some checks are pending
CI / release (push) Waiting to run
CI / debug (push) Waiting to run
CI / release_executable (push) Waiting to run
CI / debug_executable (push) Waiting to run
CI / check-phpunit (push) Waiting to run
CI / check-phpdoc (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions

This commit is contained in:
netkas 2025-03-25 14:22:46 -04:00
parent 4f9cc89cb8
commit 42168b132d
Signed by: netkas
GPG key ID: 4D8629441B76E4CC
2 changed files with 5 additions and 5 deletions

View file

@ -65,11 +65,11 @@
// Check if the contact already exists // Check if the contact already exists
if(ContactManager::isContact($peer, $peerAddress)) if(ContactManager::isContact($peer, $peerAddress))
{ {
return $rpcRequest->produceError(StandardError::FORBIDDEN, 'Contact already exists'); return $rpcRequest->produceResponse(false);
} }
// Create the contact // Create the contact
$contactUuid = ContactManager::createContact($peer, $peerAddress, $relationship); ContactManager::createContact($peer, $peerAddress, $relationship);
} }
catch (DatabaseOperationException $e) catch (DatabaseOperationException $e)
{ {
@ -77,6 +77,6 @@
} }
// Return success // Return success
return $rpcRequest->produceResponse($contactUuid); return $rpcRequest->produceResponse(true);
} }
} }

View file

@ -194,10 +194,10 @@
* *
* @param PeerAddress|string $peer The address of the peer to add as a contact * @param PeerAddress|string $peer The address of the peer to add as a contact
* @param string|ContactRelationshipType|null $relationship Optional. The relationship for the peer * @param string|ContactRelationshipType|null $relationship Optional. The relationship for the peer
* @return string Returns the contact uuid if the contact was created, False if it already exists * @return bool Returns the contact uuid if the contact was created, False if it already exists
* @throws RpcException Thrown if there was an error with the RPC request * @throws RpcException Thrown if there was an error with the RPC request
*/ */
public function addressBookAddContact(PeerAddress|string $peer, null|string|ContactRelationshipType $relationship=ContactRelationshipType::MUTUAL): string public function addressBookAddContact(PeerAddress|string $peer, null|string|ContactRelationshipType $relationship=ContactRelationshipType::MUTUAL): bool
{ {
if($peer instanceof PeerAddress) if($peer instanceof PeerAddress)
{ {