From d1cd9a016e143a8246aa4e095b76457cff7365b2 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 18 Feb 2024 18:47:59 -0500 Subject: [PATCH 1/2] Move Api\Mastodon\Instance\Extended to ExtendedDescription - Add reference to Mastodon documentation --- .../{Extended.php => ExtendedDescription.php} | 15 +++++++-------- static/routes.config.php | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) rename src/Module/Api/Mastodon/Instance/{Extended.php => ExtendedDescription.php} (77%) diff --git a/src/Module/Api/Mastodon/Instance/Extended.php b/src/Module/Api/Mastodon/Instance/ExtendedDescription.php similarity index 77% rename from src/Module/Api/Mastodon/Instance/Extended.php rename to src/Module/Api/Mastodon/Instance/ExtendedDescription.php index 98490988a6..a93141cc95 100644 --- a/src/Module/Api/Mastodon/Instance/Extended.php +++ b/src/Module/Api/Mastodon/Instance/ExtendedDescription.php @@ -25,23 +25,22 @@ use DateTime; use Friendica\App; use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\L10n; -use Friendica\Database\Database; use Friendica\Model\User; use Friendica\Module\Api\ApiResponse; use Friendica\Module\BaseApi; -use Friendica\Object\Api\Mastodon\ExtendedDescription; +use Friendica\Network\HTTPException; +use Friendica\Object\Api\Mastodon; use Friendica\Util\Profiler; use Psr\Log\LoggerInterface; /** - * Undocumented API endpoint that is implemented by both Mastodon and Pleroma + * @see https://docs.joinmastodon.org/methods/instance/#extended_description */ -class Extended extends BaseApi +class ExtendedDescription extends BaseApi { - /** @var IManageConfigValues */ - private $config; + private IManageConfigValues $config; - public function __construct(\Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, Database $database, IManageConfigValues $config, array $server, array $parameters = []) + public function __construct(\Friendica\Factory\Api\Mastodon\Error $errorFactory, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, IManageConfigValues $config, array $server, array $parameters = []) { parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); @@ -55,6 +54,6 @@ class Extended extends BaseApi { $account = User::getSystemAccount(); - $this->jsonExit(new ExtendedDescription(new DateTime($account['updated']), $this->config->get('config', 'info'))); + $this->jsonExit(new Mastodon\ExtendedDescription(new DateTime($account['updated']), $this->config->get('config', 'info'))); } } diff --git a/static/routes.config.php b/static/routes.config.php index affbf5a42a..67ffec8e2b 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -254,7 +254,7 @@ return [ '/instance' => [Module\Api\Mastodon\Instance::class, [R::GET ]], '/instance/activity' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], // @todo '/instance/domain_blocks' => [Module\Api\Mastodon\Unimplemented::class, [R::GET ]], // @todo - '/instance/extended_description' => [Module\Api\Mastodon\Instance\Extended::class, [R::GET ]], + '/instance/extended_description' => [Module\Api\Mastodon\Instance\ExtendedDescription::class, [R::GET ]], '/instance/peers' => [Module\Api\Mastodon\Instance\Peers::class, [R::GET ]], '/instance/rules' => [Module\Api\Mastodon\Instance\Rules::class, [R::GET ]], '/lists' => [Module\Api\Mastodon\Lists::class, [R::GET, R::POST]], From 623a5be8a6a41a7ae373a473d9ce3eb8e57638ba Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 18 Feb 2024 18:48:37 -0500 Subject: [PATCH 2/2] Clarify condition on offset in Mastodon\Search->searchStatuses --- src/Module/Api/Mastodon/Search.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Module/Api/Mastodon/Search.php b/src/Module/Api/Mastodon/Search.php index 9cef70972b..8f511395bc 100644 --- a/src/Module/Api/Mastodon/Search.php +++ b/src/Module/Api/Mastodon/Search.php @@ -137,7 +137,8 @@ class Search extends BaseApi private static function searchStatuses(int $uid, string $q, string $account_id, int $max_id, int $min_id, int $limit, int $offset) { if (Network::isValidHttpUrl($q)) { - if ($offset != 0) { + // Unique post search, any offset greater than 0 should return empty result + if ($offset > 0) { return []; } $q = Network::convertToIdn($q);