Made message signing in Cryptography use SHA512 as the message content for... #1
1 changed files with 8 additions and 6 deletions
|
@ -7,6 +7,8 @@
|
||||||
use Socialbox\Enums\StandardError;
|
use Socialbox\Enums\StandardError;
|
||||||
use Socialbox\Enums\Types\InformationFieldName;
|
use Socialbox\Enums\Types\InformationFieldName;
|
||||||
use Socialbox\Exceptions\DatabaseOperationException;
|
use Socialbox\Exceptions\DatabaseOperationException;
|
||||||
|
use Socialbox\Exceptions\Standard\InvalidRpcArgumentException;
|
||||||
|
use Socialbox\Exceptions\Standard\MissingRpcArgumentException;
|
||||||
use Socialbox\Exceptions\Standard\StandardRpcException;
|
use Socialbox\Exceptions\Standard\StandardRpcException;
|
||||||
use Socialbox\Interfaces\SerializableInterface;
|
use Socialbox\Interfaces\SerializableInterface;
|
||||||
use Socialbox\Managers\PeerInformationManager;
|
use Socialbox\Managers\PeerInformationManager;
|
||||||
|
@ -23,24 +25,24 @@
|
||||||
// Field parameter is required
|
// Field parameter is required
|
||||||
if(!$rpcRequest->containsParameter('field'))
|
if(!$rpcRequest->containsParameter('field'))
|
||||||
{
|
{
|
||||||
return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, 'The required field parameter is missing');
|
throw new MissingRpcArgumentException('field');
|
||||||
}
|
}
|
||||||
$fieldName = InformationFieldName::tryFrom(strtoupper($rpcRequest->getParameter('field')));
|
$fieldName = InformationFieldName::tryFrom(strtoupper($rpcRequest->getParameter('field')));
|
||||||
if($fieldName === null)
|
if($fieldName === null)
|
||||||
{
|
{
|
||||||
return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, 'The provided field parameter is invalid');
|
throw new InvalidRpcArgumentException('field');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Privacy parameter is required
|
// Privacy parameter is required
|
||||||
$privacy = null;
|
|
||||||
if(!$rpcRequest->containsParameter('privacy'))
|
if(!$rpcRequest->containsParameter('privacy'))
|
||||||
{
|
{
|
||||||
return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, 'The required privacy parameter is missing');
|
throw new MissingRpcArgumentException('privacy');
|
||||||
}
|
}
|
||||||
|
|
||||||
$privacy = PrivacyState::tryFrom(strtoupper($rpcRequest->getParameter('privacy')));
|
$privacy = PrivacyState::tryFrom(strtoupper($rpcRequest->getParameter('privacy')));
|
||||||
if($privacy === null)
|
if($privacy === null)
|
||||||
{
|
{
|
||||||
return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, 'The provided privacy parameter is invalid');
|
throw new InvalidRpcArgumentException('privacy');
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -48,7 +50,7 @@
|
||||||
$peer = $request->getPeer();
|
$peer = $request->getPeer();
|
||||||
if(!PeerInformationManager::fieldExists($peer, $fieldName))
|
if(!PeerInformationManager::fieldExists($peer, $fieldName))
|
||||||
{
|
{
|
||||||
return $rpcRequest->produceError(StandardError::FORBIDDEN, 'The information field does not exist');
|
return $rpcRequest->produceResponse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
PeerInformationManager::updatePrivacyState($peer, $fieldName, $privacy);
|
PeerInformationManager::updatePrivacyState($peer, $fieldName, $privacy);
|
||||||
|
|
Loading…
Add table
Reference in a new issue