Major changes, revamp required

This commit is contained in:
netkas 2025-02-20 00:34:07 -05:00
parent 1f9890bba0
commit 29a3d42538
20 changed files with 523 additions and 662 deletions

View file

@ -1,59 +0,0 @@
<?php
namespace Socialbox\Classes\StandardMethods\Core;
use Exception;
use InvalidArgumentException;
use Socialbox\Abstracts\Method;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\Standard\InvalidRpcArgumentException;
use Socialbox\Exceptions\Standard\MissingRpcArgumentException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Objects\ClientRequest;
use Socialbox\Objects\PeerAddress;
use Socialbox\Objects\RpcRequest;
use Socialbox\Socialbox;
use Symfony\Component\Uid\Uuid;
class ResolvePeerSignature extends Method
{
/**
* @inheritDoc
*/
public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface
{
// Check if the required 'peer' parameter is set.
if(!$rpcRequest->containsParameter('peer'))
{
throw new MissingRpcArgumentException('peer');
}
if(!$rpcRequest->containsParameter('uuid'))
{
throw new MissingRpcArgumentException('uuid');
}
try
{
$uuid = Uuid::fromString($rpcRequest->getParameter('uuid'));
}
catch(InvalidArgumentException $e)
{
throw new InvalidRpcArgumentException('uuid', $e);
}
// Parse the peer address
try
{
$peerAddress = PeerAddress::fromAddress($rpcRequest->getParameter('peer'));
}
catch(InvalidArgumentException $e)
{
throw new InvalidRpcArgumentException('peer', $e);
}
return $rpcRequest->produceResponse(Socialbox::resolvePeerSignature($peerAddress, $uuid->toRfc4122()));
}
}