Refactor AddressBookAddContact to prevent adding self and reserved usernames as contacts
https://github.com/nosial/Socialbox-PHP/issues/30
This commit is contained in:
parent
86050e2201
commit
1d6820a4f1
1 changed files with 5 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Socialbox\Abstracts\Method;
|
use Socialbox\Abstracts\Method;
|
||||||
|
use Socialbox\Enums\ReservedUsernames;
|
||||||
use Socialbox\Enums\StandardError;
|
use Socialbox\Enums\StandardError;
|
||||||
use Socialbox\Enums\Types\ContactRelationshipType;
|
use Socialbox\Enums\Types\ContactRelationshipType;
|
||||||
use Socialbox\Exceptions\DatabaseOperationException;
|
use Socialbox\Exceptions\DatabaseOperationException;
|
||||||
|
@ -54,6 +55,10 @@
|
||||||
{
|
{
|
||||||
return $rpcRequest->produceError(StandardError::FORBIDDEN, 'Cannot add self as contact');
|
return $rpcRequest->produceError(StandardError::FORBIDDEN, 'Cannot add self as contact');
|
||||||
}
|
}
|
||||||
|
elseif($peer->getUsername() === ReservedUsernames::HOST->value)
|
||||||
|
{
|
||||||
|
return $rpcRequest->produceError(StandardError::FORBIDDEN, 'Cannot add host 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($peerAddress);
|
Socialbox::resolvePeer($peerAddress);
|
||||||
|
|
Loading…
Add table
Reference in a new issue