39 lines
No EOL
1.3 KiB
PHP
39 lines
No EOL
1.3 KiB
PHP
<?php
|
|
|
|
namespace Socialbox\Classes\StandardMethods;
|
|
|
|
use Exception;
|
|
use Socialbox\Abstracts\Method;
|
|
use Socialbox\Classes\Configuration;
|
|
use Socialbox\Enums\StandardError;
|
|
use Socialbox\Exceptions\StandardException;
|
|
use Socialbox\Interfaces\SerializableInterface;
|
|
use Socialbox\Managers\RegisteredPeerManager;
|
|
use Socialbox\Objects\ClientRequest;
|
|
use Socialbox\Objects\RpcRequest;
|
|
|
|
class SettingsDeleteDisplayName extends Method
|
|
{
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface
|
|
{
|
|
if(Configuration::getRegistrationConfiguration()->isDisplayNameRequired())
|
|
{
|
|
return $rpcRequest->produceError(StandardError::FORBIDDEN, 'A display name is required for this server');
|
|
}
|
|
|
|
try
|
|
{
|
|
// Set the password
|
|
RegisteredPeerManager::deleteDisplayName($request->getPeer());
|
|
}
|
|
catch(Exception $e)
|
|
{
|
|
throw new StandardException('Failed to set password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
|
|
}
|
|
|
|
return $rpcRequest->produceResponse(true);
|
|
}
|
|
} |