Added self-contact check

This commit is contained in:
netkas 2025-01-27 02:35:53 -05:00
parent 8d5a95da9b
commit 481ea884f2

View file

@ -51,11 +51,16 @@
try 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 // Resolve the peer, this would throw a StandardException if something goes wrong
Socialbox::resolvePeer($address); Socialbox::resolvePeer($address);
// Check if the contact already exists // Check if the contact already exists
$peer = $request->getPeer();
if(ContactManager::isContact($peer, $address)) if(ContactManager::isContact($peer, $address))
{ {
return $rpcRequest->produceError(StandardError::FORBIDDEN, 'Contact already exists'); return $rpcRequest->produceError(StandardError::FORBIDDEN, 'Contact already exists');