Implement GetBlacklistRecord functionality to retrieve specific blacklist entries
Some checks are pending
CI / release (push) Waiting to run
CI / debug (push) Waiting to run
CI / check-phpunit (push) Waiting to run
CI / check-phpdoc (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
Some checks are pending
CI / release (push) Waiting to run
CI / debug (push) Waiting to run
CI / check-phpunit (push) Waiting to run
CI / check-phpdoc (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
This commit is contained in:
parent
663ce2ceac
commit
8ec47c855f
2 changed files with 57 additions and 4 deletions
|
@ -10,6 +10,7 @@
|
||||||
use FederationServer\Methods\Audit\ViewAuditEntry;
|
use FederationServer\Methods\Audit\ViewAuditEntry;
|
||||||
use FederationServer\Methods\Blacklist\BlacklistEntity;
|
use FederationServer\Methods\Blacklist\BlacklistEntity;
|
||||||
use FederationServer\Methods\Blacklist\DeleteBlacklist;
|
use FederationServer\Methods\Blacklist\DeleteBlacklist;
|
||||||
|
use FederationServer\Methods\Blacklist\GetBlacklistRecord;
|
||||||
use FederationServer\Methods\Blacklist\LiftBlacklist;
|
use FederationServer\Methods\Blacklist\LiftBlacklist;
|
||||||
use FederationServer\Methods\Blacklist\ListBlacklist;
|
use FederationServer\Methods\Blacklist\ListBlacklist;
|
||||||
use FederationServer\Methods\Entities\DeleteEntity;
|
use FederationServer\Methods\Entities\DeleteEntity;
|
||||||
|
@ -204,11 +205,9 @@
|
||||||
case self::LIFT_BLACKLIST:
|
case self::LIFT_BLACKLIST:
|
||||||
LiftBlacklist::handleRequest();
|
LiftBlacklist::handleRequest();
|
||||||
break;
|
break;
|
||||||
case self::BLACKLIST_ATTACH_EVIDENCE:
|
|
||||||
throw new \Exception('To be implemented');
|
|
||||||
break;
|
|
||||||
case self::GET_BLACKLIST_RECORD:
|
case self::GET_BLACKLIST_RECORD:
|
||||||
throw new \Exception('To be implemented');
|
GetBlacklistRecord::handleRequest();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace FederationServer\Methods\Blacklist;
|
||||||
|
|
||||||
|
use FederationServer\Classes\Configuration;
|
||||||
|
use FederationServer\Classes\Managers\BlacklistManager;
|
||||||
|
use FederationServer\Classes\RequestHandler;
|
||||||
|
use FederationServer\Classes\Validate;
|
||||||
|
use FederationServer\Exceptions\DatabaseOperationException;
|
||||||
|
use FederationServer\Exceptions\RequestException;
|
||||||
|
use FederationServer\FederationServer;
|
||||||
|
|
||||||
|
class GetBlacklistRecord extends RequestHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function handleRequest(): void
|
||||||
|
{
|
||||||
|
$authenticatedOperator = FederationServer::getAuthenticatedOperator();
|
||||||
|
if(!Configuration::getServerConfiguration() ->isBlacklistPublic() && $authenticatedOperator === null)
|
||||||
|
{
|
||||||
|
throw new RequestException('You must be authenticated to view blacklist records', 401);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!preg_match('#^/blacklist/([a-fA-F0-9\-]{36,})$#', FederationServer::getPath(), $matches))
|
||||||
|
{
|
||||||
|
throw new RequestException('Blacklist UUID required', 405);
|
||||||
|
}
|
||||||
|
|
||||||
|
$blacklistUuid = $matches[1];
|
||||||
|
if(!$blacklistUuid || !Validate::uuid($blacklistUuid))
|
||||||
|
{
|
||||||
|
throw new RequestException('Invalid blacklist UUID', 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(!BlacklistManager::blacklistExists($blacklistUuid))
|
||||||
|
{
|
||||||
|
throw new RequestException('Blacklist record not found', 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$blacklistRecord = BlacklistManager::getBlacklistEntry($blacklistUuid);
|
||||||
|
}
|
||||||
|
catch (DatabaseOperationException $e)
|
||||||
|
{
|
||||||
|
throw new RequestException('Unable to retrieve blacklist records', 500, $e);
|
||||||
|
}
|
||||||
|
|
||||||
|
self::successResponse($blacklistRecord->toArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue