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
This commit is contained in:
netkas 2025-03-07 19:28:38 -05:00
parent 724b2ae472
commit 7165734aef
2 changed files with 1 additions and 7 deletions

View file

@ -4,10 +4,8 @@
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\MissingRpcArgumentException; use Socialbox\Exceptions\Standard\MissingRpcArgumentException;
use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface; use Socialbox\Interfaces\SerializableInterface;
@ -27,10 +25,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()->getEncryptionChannelOutgoingLimit(); $limit = Configuration::getPoliciesConfiguration()->getEncryptionChannelOutgoingLimit();

View file

@ -419,7 +419,7 @@
try try
{ {
$offset = ($page -1) * $limit; $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(':peer_address', $peerAddress);
$stmt->bindParam(':limit', $limit); $stmt->bindParam(':limit', $limit);
$stmt->bindParam(':offset', $offset); $stmt->bindParam(':offset', $offset);