Add support for SerializableInterface in successResponse method of RequestHandler

This commit is contained in:
netkas 2025-06-03 17:22:35 -04:00
parent a4555ade9b
commit 13e128591f
Signed by: netkas
GPG key ID: 4D8629441B76E4CC

View file

@ -6,6 +6,7 @@
use FederationServer\Exceptions\DatabaseOperationException; use FederationServer\Exceptions\DatabaseOperationException;
use FederationServer\Exceptions\RequestException; use FederationServer\Exceptions\RequestException;
use FederationServer\Interfaces\RequestHandlerInterface; use FederationServer\Interfaces\RequestHandlerInterface;
use FederationServer\Interfaces\SerializableInterface;
use FederationServer\Objects\OperatorRecord; use FederationServer\Objects\OperatorRecord;
use Throwable; use Throwable;
@ -128,6 +129,11 @@
*/ */
protected static function successResponse(mixed $data=null): void protected static function successResponse(mixed $data=null): void
{ {
if($data instanceof SerializableInterface)
{
$data = $data->toArray();
}
http_response_code(200); http_response_code(200);
self::returnHeaders(); self::returnHeaders();
print(json_encode([ print(json_encode([