From ea3a070d135c1071938163d1d60a2b6f238dfba5 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 7 Mar 2025 21:47:49 -0500 Subject: [PATCH] Refactor EncryptionGetChannelRequests and EncryptionChannelManager to remove UUID validation and improve peer address handling https://github.com/nosial/Socialbox-PHP/issues/23 --- .../EncryptionChannel/EncryptionGetChannelRequests.php | 5 ----- src/Socialbox/Managers/EncryptionChannelManager.php | 10 +++++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Socialbox/Classes/StandardMethods/EncryptionChannel/EncryptionGetChannelRequests.php b/src/Socialbox/Classes/StandardMethods/EncryptionChannel/EncryptionGetChannelRequests.php index 6edebf8..5b40202 100644 --- a/src/Socialbox/Classes/StandardMethods/EncryptionChannel/EncryptionGetChannelRequests.php +++ b/src/Socialbox/Classes/StandardMethods/EncryptionChannel/EncryptionGetChannelRequests.php @@ -5,7 +5,6 @@ use InvalidArgumentException; use Socialbox\Abstracts\Method; use Socialbox\Classes\Configuration; - use Socialbox\Classes\Validator; use Socialbox\Enums\StandardError; use Socialbox\Exceptions\DatabaseOperationException; use Socialbox\Exceptions\Standard\InvalidRpcArgumentException; @@ -28,10 +27,6 @@ { 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; $limit = Configuration::getPoliciesConfiguration()->getEncryptionChannelRequestsLimit(); diff --git a/src/Socialbox/Managers/EncryptionChannelManager.php b/src/Socialbox/Managers/EncryptionChannelManager.php index 2e7a4da..662d549 100644 --- a/src/Socialbox/Managers/EncryptionChannelManager.php +++ b/src/Socialbox/Managers/EncryptionChannelManager.php @@ -451,15 +451,15 @@ */ public static function getChannelRequests(string|PeerAddress $peerAddress, int $page=1, int $limit=100): array { - if($peerAddress instanceof PeerAddress) - { - $peerAddress = $peerAddress->getAddress(); - } - elseif(!Validator::validatePeerAddress($peerAddress)) + if(is_string($peerAddress) && !Validator::validatePeerAddress($peerAddress)) { throw new InvalidArgumentException('Invalid Peer Address'); } + if($peerAddress instanceof PeerAddress) + { + $peerAddress = $peerAddress->getAddress(); + } if($page < 1) {