Cast channel and message UUIDs to string in EncryptionChannelAcknowledgeMessage

https://github.com/nosial/Socialbox-PHP/issues/14
This commit is contained in:
netkas 2025-03-07 15:01:48 -05:00
parent 5109796f76
commit 78c5a22c15

View file

@ -5,12 +5,10 @@
use Exception; use Exception;
use Socialbox\Abstracts\Method; use Socialbox\Abstracts\Method;
use Socialbox\Classes\Logger; use Socialbox\Classes\Logger;
use Socialbox\Classes\Validator;
use Socialbox\Enums\StandardError; use Socialbox\Enums\StandardError;
use Socialbox\Enums\Status\EncryptionChannelStatus; use Socialbox\Enums\Status\EncryptionChannelStatus;
use Socialbox\Exceptions\DatabaseOperationException; use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\RpcException; use Socialbox\Exceptions\RpcException;
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;
@ -32,23 +30,11 @@
{ {
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');
}
if(!$rpcRequest->containsParameter('message_uuid')) if(!$rpcRequest->containsParameter('message_uuid'))
{ {
throw new MissingRpcArgumentException('message_uuid'); throw new MissingRpcArgumentException('message_uuid');
} }
elseif(!is_string($rpcRequest->getParameter('message_uuid')))
{
throw new InvalidRpcArgumentException('message_uuid', 'Must be type string');
}
elseif(!Validator::validateUuid($rpcRequest->getParameter('message_uuid')))
{
throw new InvalidRpcArgumentException('message_uuid', 'Invalid message UUID V4');
}
try try
{ {
@ -177,7 +163,7 @@
} }
EncryptionChannelManager::acknowledgeMessage( EncryptionChannelManager::acknowledgeMessage(
$rpcRequest->getParameter('channel_uuid'), $rpcRequest->getParameter('message_uuid') (string)$rpcRequest->getParameter('channel_uuid'), (string)$rpcRequest->getParameter('message_uuid')
); );
} }
catch(DatabaseOperationException $e) catch(DatabaseOperationException $e)
@ -191,8 +177,8 @@
{ {
$rpcClient = Socialbox::getExternalSession($message->getOwner($encryptionChannel)->getDomain()); $rpcClient = Socialbox::getExternalSession($message->getOwner($encryptionChannel)->getDomain());
$rpcClient->encryptionChannelAcknowledgeMessage( $rpcClient->encryptionChannelAcknowledgeMessage(
channelUuid: $rpcRequest->getParameter('channel_uuid'), channelUuid: (string)$rpcRequest->getParameter('channel_uuid'),
messageUuid: $rpcRequest->getParameter('message_uuid'), messageUuid: (string)$rpcRequest->getParameter('message_uuid'),
identifiedAs: $requestingPeer->getAddress() identifiedAs: $requestingPeer->getAddress()
); );
} }