Made message signing in Cryptography use SHA512 as the message content for... #1
1 changed files with 46 additions and 0 deletions
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace Socialbox\Classes\StandardMethods\Settings;
|
||||
|
||||
use Socialbox\Abstracts\Method;
|
||||
use Socialbox\Enums\StandardError;
|
||||
use Socialbox\Enums\Types\InformationFieldName;
|
||||
use Socialbox\Exceptions\DatabaseOperationException;
|
||||
use Socialbox\Exceptions\Standard\InvalidRpcArgumentException;
|
||||
use Socialbox\Exceptions\Standard\MissingRpcArgumentException;
|
||||
use Socialbox\Exceptions\Standard\StandardRpcException;
|
||||
use Socialbox\Interfaces\SerializableInterface;
|
||||
use Socialbox\Managers\PeerInformationManager;
|
||||
use Socialbox\Objects\ClientRequest;
|
||||
use Socialbox\Objects\RpcRequest;
|
||||
|
||||
class SettingsInformationFieldExists extends Method
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @noinspection DuplicatedCode
|
||||
*/
|
||||
public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface
|
||||
{
|
||||
// Field parameter is required
|
||||
if(!$rpcRequest->containsParameter('field'))
|
||||
{
|
||||
throw new MissingRpcArgumentException('field');
|
||||
}
|
||||
$fieldName = InformationFieldName::tryFrom(strtoupper($rpcRequest->getParameter('field')));
|
||||
if($fieldName === null)
|
||||
{
|
||||
throw new InvalidRpcArgumentException('field');
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return $rpcRequest->produceResponse(PeerInformationManager::fieldExists($request->getPeer(), $fieldName));
|
||||
|
||||
}
|
||||
catch(DatabaseOperationException $e)
|
||||
{
|
||||
throw new StandardRpcException('Failed to check if the requested information field exists or not', StandardError::INTERNAL_SERVER_ERROR, $e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue