Refactor EncryptionGetChannelRequests and EncryptionChannelManager to remove UUID validation and improve peer address handling
https://github.com/nosial/Socialbox-PHP/issues/23
This commit is contained in:
parent
0ff277ed4c
commit
ea3a070d13
2 changed files with 5 additions and 10 deletions
|
@ -5,7 +5,6 @@
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Socialbox\Abstracts\Method;
|
use Socialbox\Abstracts\Method;
|
||||||
use Socialbox\Classes\Configuration;
|
use Socialbox\Classes\Configuration;
|
||||||
use Socialbox\Classes\Validator;
|
|
||||||
use Socialbox\Enums\StandardError;
|
use Socialbox\Enums\StandardError;
|
||||||
use Socialbox\Exceptions\DatabaseOperationException;
|
use Socialbox\Exceptions\DatabaseOperationException;
|
||||||
use Socialbox\Exceptions\Standard\InvalidRpcArgumentException;
|
use Socialbox\Exceptions\Standard\InvalidRpcArgumentException;
|
||||||
|
@ -28,10 +27,6 @@
|
||||||
{
|
{
|
||||||
throw new MissingRpcArgumentException('channel_uuid');
|
throw new MissingRpcArgumentException('channel_uuid');
|
||||||
}
|
}
|
||||||
elseif(!Validator::validateUuid($rpcRequest->getParameter('channel_uuid')))
|
|
||||||
{
|
|
||||||
throw new InvalidRpcArgumentException('channel_uuid', 'The given channel uuid is not a valid UUID V4');
|
|
||||||
}
|
|
||||||
|
|
||||||
$page = 1;
|
$page = 1;
|
||||||
$limit = Configuration::getPoliciesConfiguration()->getEncryptionChannelRequestsLimit();
|
$limit = Configuration::getPoliciesConfiguration()->getEncryptionChannelRequestsLimit();
|
||||||
|
|
|
@ -451,15 +451,15 @@
|
||||||
*/
|
*/
|
||||||
public static function getChannelRequests(string|PeerAddress $peerAddress, int $page=1, int $limit=100): array
|
public static function getChannelRequests(string|PeerAddress $peerAddress, int $page=1, int $limit=100): array
|
||||||
{
|
{
|
||||||
if($peerAddress instanceof PeerAddress)
|
if(is_string($peerAddress) && !Validator::validatePeerAddress($peerAddress))
|
||||||
{
|
|
||||||
$peerAddress = $peerAddress->getAddress();
|
|
||||||
}
|
|
||||||
elseif(!Validator::validatePeerAddress($peerAddress))
|
|
||||||
{
|
{
|
||||||
throw new InvalidArgumentException('Invalid Peer Address');
|
throw new InvalidArgumentException('Invalid Peer Address');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($peerAddress instanceof PeerAddress)
|
||||||
|
{
|
||||||
|
$peerAddress = $peerAddress->getAddress();
|
||||||
|
}
|
||||||
|
|
||||||
if($page < 1)
|
if($page < 1)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue