Transform ApiResponse::unspported() into dynamic method
This commit is contained in:
parent
ebf56674f1
commit
5bfcc8b91c
|
@ -6,7 +6,6 @@ use Friendica\App\Arguments;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Object\Api\Mastodon\Error;
|
||||
use Friendica\Util\Arrays;
|
||||
use Friendica\Util\HTTPInputData;
|
||||
|
@ -199,9 +198,9 @@ class ApiResponse
|
|||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function unsupported(string $method = 'all')
|
||||
public function unsupported(string $method = 'all')
|
||||
{
|
||||
$path = DI::args()->getQueryString();
|
||||
$path = $this->args->getQueryString();
|
||||
Logger::info('Unimplemented API call',
|
||||
[
|
||||
'method' => $method,
|
||||
|
@ -209,8 +208,8 @@ class ApiResponse
|
|||
'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '',
|
||||
'request' => HTTPInputData::process()
|
||||
]);
|
||||
$error = DI::l10n()->t('API endpoint %s %s is not implemented', strtoupper($method), $path);
|
||||
$error_description = DI::l10n()->t('The API endpoint is currently not implemented but might be in the future.');
|
||||
$error = $this->l10n->t('API endpoint %s %s is not implemented', strtoupper($method), $path);
|
||||
$error_description = $this->l10n->t('The API endpoint is currently not implemented but might be in the future.');
|
||||
$errorobj = new Error($error, $error_description);
|
||||
System::jsonError(501, $errorobj->toArray());
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace Friendica\Module\Api\Mastodon\Accounts;
|
|||
|
||||
use Friendica\App\Router;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Module\Api\ApiResponse;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Util\HTTPInputData;
|
||||
|
||||
|
@ -41,6 +41,6 @@ class UpdateCredentials extends BaseApi
|
|||
|
||||
Logger::info('Patch data', ['data' => $data]);
|
||||
|
||||
ApiResponse::unsupported(Router::PATCH);
|
||||
DI::apiResponse()->unsupported(Router::PATCH);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace Friendica\Module\Api\Mastodon;
|
|||
|
||||
use Friendica\App\Router;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Module\Api\ApiResponse;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseApi;
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@ class Filters extends BaseApi
|
|||
{
|
||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||
|
||||
ApiResponse::unsupported(Router::POST);
|
||||
DI::apiResponse()->unsupported(Router::POST);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,12 +37,12 @@ class Accounts extends BaseApi
|
|||
{
|
||||
public static function delete(array $parameters = [])
|
||||
{
|
||||
ApiResponse::unsupported(Router::DELETE);
|
||||
DI::apiResponse()->unsupported(Router::DELETE);
|
||||
}
|
||||
|
||||
public static function post(array $parameters = [])
|
||||
{
|
||||
ApiResponse::unsupported(Router::POST);
|
||||
DI::apiResponse()->unsupported(Router::POST);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace Friendica\Module\Api\Mastodon;
|
|||
|
||||
use Friendica\App\Router;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Module\Api\ApiResponse;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseApi;
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@ class Markers extends BaseApi
|
|||
{
|
||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||
|
||||
ApiResponse::unsupported(Router::POST);
|
||||
DI::apiResponse()->unsupported(Router::POST);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,7 +39,7 @@ class ScheduledStatuses extends BaseApi
|
|||
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||
$uid = self::getCurrentUserID();
|
||||
|
||||
ApiResponse::unsupported(Router::PUT);
|
||||
DI::apiResponse()->unsupported(Router::PUT);
|
||||
}
|
||||
|
||||
public static function delete(array $parameters = [])
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
namespace Friendica\Module\Api\Mastodon;
|
||||
|
||||
use Friendica\App\Router;
|
||||
use Friendica\Module\Api\ApiResponse;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseApi;
|
||||
|
||||
/**
|
||||
|
@ -36,7 +36,7 @@ class Unimplemented extends BaseApi
|
|||
*/
|
||||
public static function delete(array $parameters = [])
|
||||
{
|
||||
ApiResponse::unsupported(Router::DELETE);
|
||||
DI::apiResponse()->unsupported(Router::DELETE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ class Unimplemented extends BaseApi
|
|||
*/
|
||||
public static function patch(array $parameters = [])
|
||||
{
|
||||
ApiResponse::unsupported(Router::PATCH);
|
||||
DI::apiResponse()->unsupported(Router::PATCH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,7 +54,7 @@ class Unimplemented extends BaseApi
|
|||
*/
|
||||
public static function post(array $parameters = [])
|
||||
{
|
||||
ApiResponse::unsupported(Router::POST);
|
||||
DI::apiResponse()->unsupported(Router::POST);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,7 +63,7 @@ class Unimplemented extends BaseApi
|
|||
*/
|
||||
public static function put(array $parameters = [])
|
||||
{
|
||||
ApiResponse::unsupported(Router::PUT);
|
||||
DI::apiResponse()->unsupported(Router::PUT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,6 +72,6 @@ class Unimplemented extends BaseApi
|
|||
*/
|
||||
public static function rawContent(array $parameters = [])
|
||||
{
|
||||
ApiResponse::unsupported(Router::GET);
|
||||
DI::apiResponse()->unsupported(Router::GET);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user