From d7b573c6d76a9ac430134faa9936e806224df860 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 20 Feb 2022 16:19:22 -0500 Subject: [PATCH] Update Mastodon API version string to include Mastodon version compatibility --- src/Module/Api/Mastodon/Instance.php | 27 +++++++++++++++++++++++++-- src/Object/Api/Mastodon/Instance.php | 2 +- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/Module/Api/Mastodon/Instance.php b/src/Module/Api/Mastodon/Instance.php index 6d3db9018..e5e0a9579 100644 --- a/src/Module/Api/Mastodon/Instance.php +++ b/src/Module/Api/Mastodon/Instance.php @@ -21,21 +21,44 @@ namespace Friendica\Module\Api\Mastodon; +use Friendica\App; +use Friendica\Core\Config\Capability\IManageConfigValues; +use Friendica\Core\L10n; use Friendica\Core\System; -use Friendica\DI; +use Friendica\Database\Database; +use Friendica\Module\Api\ApiResponse; use Friendica\Module\BaseApi; use Friendica\Object\Api\Mastodon\Instance as InstanceEntity; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; /** * @see https://docs.joinmastodon.org/api/rest/instances/ */ class Instance extends BaseApi { + /** @var Database */ + private $database; + + /** @var IManageConfigValues */ + private $config; + + public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, Database $database, IManageConfigValues $config, array $server, array $parameters = []) + { + parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + + $this->database = $database; + $this->config = $config; + } + /** + * @param array $request * @throws \Friendica\Network\HTTPException\InternalServerErrorException + * @throws \Friendica\Network\HTTPException\NotFoundException + * @throws \ImagickException */ protected function rawContent(array $request = []) { - System::jsonExit(new InstanceEntity(DI::config(), $this->baseUrl, DI::dba())); + System::jsonExit(new InstanceEntity($this->config, $this->baseUrl, $this->database)); } } diff --git a/src/Object/Api/Mastodon/Instance.php b/src/Object/Api/Mastodon/Instance.php index 4337c3d1f..0ae96c972 100644 --- a/src/Object/Api/Mastodon/Instance.php +++ b/src/Object/Api/Mastodon/Instance.php @@ -87,7 +87,7 @@ class Instance extends BaseDataTransferObject $this->title = $config->get('config', 'sitename'); $this->short_description = $this->description = $config->get('config', 'info'); $this->email = $config->get('config', 'admin_email'); - $this->version = FRIENDICA_VERSION; + $this->version = '2.8.0 (compatible; Friendica ' . FRIENDICA_VERSION . ')'; $this->urls = null; // Not supported $this->stats = new Stats($config, $database); $this->thumbnail = $baseUrl->get() . ($config->get('system', 'shortcut_icon') ?? 'images/friendica-32.png');