From 481ea884f201d8a96ede112af20325792c45177c Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 27 Jan 2025 02:35:53 -0500 Subject: [PATCH] Added self-contact check --- .../Classes/StandardMethods/AddressBookAddContact.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Socialbox/Classes/StandardMethods/AddressBookAddContact.php b/src/Socialbox/Classes/StandardMethods/AddressBookAddContact.php index 70442ca..ebad0d1 100644 --- a/src/Socialbox/Classes/StandardMethods/AddressBookAddContact.php +++ b/src/Socialbox/Classes/StandardMethods/AddressBookAddContact.php @@ -51,11 +51,16 @@ try { + $peer = $request->getPeer(); + if($peer->getAddress() == $address) + { + return $rpcRequest->produceError(StandardError::FORBIDDEN, 'Cannot add self as contact'); + } + // Resolve the peer, this would throw a StandardException if something goes wrong Socialbox::resolvePeer($address); // Check if the contact already exists - $peer = $request->getPeer(); if(ContactManager::isContact($peer, $address)) { return $rpcRequest->produceError(StandardError::FORBIDDEN, 'Contact already exists');