From 7165734aef53d99639a6558bd6911d6a19013334 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 7 Mar 2025 19:28:38 -0500 Subject: [PATCH] Refactor EncryptionGetOutgoingChannels and EncryptionChannelManager to remove UUID validation and adjust SQL query for ordering by creation date https://github.com/nosial/Socialbox-PHP/issues/26 --- .../EncryptionChannel/EncryptionGetOutgoingChannels.php | 6 ------ src/Socialbox/Managers/EncryptionChannelManager.php | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Socialbox/Classes/StandardMethods/EncryptionChannel/EncryptionGetOutgoingChannels.php b/src/Socialbox/Classes/StandardMethods/EncryptionChannel/EncryptionGetOutgoingChannels.php index b31c332..c46c8c7 100644 --- a/src/Socialbox/Classes/StandardMethods/EncryptionChannel/EncryptionGetOutgoingChannels.php +++ b/src/Socialbox/Classes/StandardMethods/EncryptionChannel/EncryptionGetOutgoingChannels.php @@ -4,10 +4,8 @@ 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; use Socialbox\Exceptions\Standard\MissingRpcArgumentException; use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; @@ -27,10 +25,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()->getEncryptionChannelOutgoingLimit(); diff --git a/src/Socialbox/Managers/EncryptionChannelManager.php b/src/Socialbox/Managers/EncryptionChannelManager.php index f5249a8..2e7a4da 100644 --- a/src/Socialbox/Managers/EncryptionChannelManager.php +++ b/src/Socialbox/Managers/EncryptionChannelManager.php @@ -419,7 +419,7 @@ try { $offset = ($page -1) * $limit; - $stmt = Database::getConnection()->prepare('SELECT * FROM encryption_channels WHERE calling_peer_address=:peer_address LIMIT :limit OFFSET :offset'); + $stmt = Database::getConnection()->prepare('SELECT * FROM encryption_channels WHERE calling_peer_address=:peer_address ORDER BY created LIMIT :limit OFFSET :offset'); $stmt->bindParam(':peer_address', $peerAddress); $stmt->bindParam(':limit', $limit); $stmt->bindParam(':offset', $offset);