use Friendica\Module\Api\ApiResponse;
use Friendica\Module\BaseApi;
use Friendica\Object\Api\Mastodon\Instance as InstanceEntity;
+use Friendica\Object\Api\Mastodon\InstanceV2 as InstanceV2Entity;
+use Friendica\Util\Images;
use Friendica\Util\Profiler;
+use Friendica\Util\Strings;
use Psr\Log\LoggerInterface;
/**
*/
protected function rawContent(array $request = [])
{
- $this->jsonExit(new InstanceEntity($this->config, $this->baseUrl, $this->database, System::getRules()));
+ $this->jsonExit(new InstanceEntity($this->config, $this->baseUrl, $this->database, System::getRules(), $this->buildConfigurationInfo()));
+ }
+
+ private function buildConfigurationInfo(): InstanceV2Entity\Configuration
+ {
+ $statuses_config = new InstanceV2Entity\StatusesConfig((int)$this->config->get(
+ 'config',
+ 'api_import_size',
+ $this->config->get('config', 'max_import_size')
+ ), 99, 23);
+
+ $image_size_limit = Strings::getBytesFromShorthand($this->config->get('system', 'maximagesize'));
+ $max_image_length = $this->config->get('system', 'max_image_length');
+ if ($max_image_length > 0) {
+ $image_matrix_limit = pow($max_image_length, 2);
+ } else {
+ $image_matrix_limit = 33177600; // 5760^2
+ }
+
+ return new InstanceV2Entity\Configuration(
+ $statuses_config,
+ new InstanceV2Entity\MediaAttachmentsConfig(array_keys(Images::supportedTypes()), $image_size_limit, $image_matrix_limit),
+ new InstanceV2Entity\Polls(),
+ new InstanceV2Entity\Accounts(),
+ );
}
}
'config',
'api_import_size',
$this->config->get('config', 'max_import_size')
- ));
+ ), 99, 23);
$image_size_limit = Strings::getBytesFromShorthand($this->config->get('system', 'maximagesize'));
+ $max_image_length = $this->config->get('system', 'max_image_length');
+ if ($max_image_length > 0) {
+ $image_matrix_limit = pow($max_image_length, 2);
+ } else {
+ $image_matrix_limit = 33177600; // 5760^2
+ }
return new InstanceEntity\Configuration(
$statuses_config,
- new InstanceEntity\MediaAttachmentsConfig(Images::supportedTypes(), $image_size_limit),
+ new InstanceEntity\MediaAttachmentsConfig(array_keys(Images::supportedTypes()), $image_size_limit, $image_matrix_limit),
+ new InstanceEntity\Polls(),
+ new InstanceEntity\Accounts(),
);
}
use Friendica\Model\User;
use Friendica\Module\Register;
use Friendica\Network\HTTPException;
+use Friendica\Object\Api\Mastodon\InstanceV2\Configuration;
/**
* Class Instance
/** @var bool */
protected $invites_enabled;
/** @var Account|null */
+ /** @var Configuration */
+ protected $configuration;
protected $contact_account = null;
/** @var array */
protected $rules = [];
* @throws HTTPException\NotFoundException
* @throws \ImagickException
*/
- public function __construct(IManageConfigValues $config, BaseURL $baseUrl, Database $database, array $rules = [])
+ public function __construct(IManageConfigValues $config, BaseURL $baseUrl, Database $database, array $rules = [], Configuration $configuration)
{
$register_policy = intval($config->get('config', 'register_policy'));
$this->registrations = ($register_policy != Register::CLOSED);
$this->approval_required = ($register_policy == Register::APPROVE);
$this->invites_enabled = false;
+ $this->configuration = $configuration;
$this->contact_account = [];
$this->rules = $rules;
--- /dev/null
+<?php
+/**
+ * @copyright Copyright (C) 2010-2023, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Object\Api\Mastodon\InstanceV2;
+
+use Friendica\BaseDataTransferObject;
+
+/**
+ * Class Accounts
+ *
+ * @see https://docs.joinmastodon.org/entities/Instance/
+ */
+class Accounts extends BaseDataTransferObject
+{
+ /** @var int */
+ protected $max_featured_tags = 0;
+}
*/
class Configuration extends BaseDataTransferObject
{
+ /** @var Accounts */
+ protected $accounts;
/** @var StatusesConfig */
protected $statuses;
/** @var MediaAttachmentsConfig */
protected $media_attachments;
+ /** @var Polls */
+ protected $polls;
/**
* @param StatusesConfig $statuses
*/
public function __construct(
StatusesConfig $statuses,
- MediaAttachmentsConfig $media_attachments
+ MediaAttachmentsConfig $media_attachments,
+ Polls $polls,
+ Accounts $accounts,
) {
+ $this->accounts = $accounts;
$this->statuses = $statuses;
$this->media_attachments = $media_attachments;
+ $this->polls = $polls;
}
}
protected $supported_mime_types;
/** @var int */
protected $image_size_limit;
+ /** @var int */
+ protected $image_matrix_limit;
+ /** @var int */
+ protected $video_size_limit = 0;
+ /** @var int */
+ protected $video_frame_rate_limit = 0;
+ /** @var int */
+ protected $video_matrix_limit = 0;
/**
* @param array $supported_mime_types
*/
- public function __construct(array $supported_mime_types, int $image_size_limit)
+ public function __construct(array $supported_mime_types, int $image_size_limit, int $image_matrix_limit)
{
$this->supported_mime_types = $supported_mime_types;
$this->image_size_limit = $image_size_limit;
+ $this->image_matrix_limit = $image_matrix_limit;
}
}
--- /dev/null
+<?php
+/**
+ * @copyright Copyright (C) 2010-2023, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Object\Api\Mastodon\InstanceV2;
+
+use Friendica\BaseDataTransferObject;
+
+/**
+ * Class Polls
+ *
+ * @see https://docs.joinmastodon.org/entities/Instance/
+ */
+class Polls extends BaseDataTransferObject
+{
+ /** @var int */
+ protected $max_options = 0;
+ /** @var int */
+ protected $max_characters_per_option = 0;
+ /** @var int */
+ protected $min_expiration = 0;
+ /** @var int */
+ protected $max_expiration = 0;
+}
protected $enabled;
/** @var bool */
protected $approval_required;
+ /** @var string|null */
+ protected $message;
+ /** @var string|null */
+ protected $url;
/**
* @param bool $enabled
{
/** @var int */
protected $max_characters = 0;
+ /** @var int */
+ protected $max_media_attachments = 0;
+ /** @var int */
+ protected $characters_reserved_per_url = 0;
/**
* @param int $max_characters
+ * @param int $max_media_attachments
+ * @param int $characters_reserved_per_url
*/
- public function __construct(int $max_characters)
+ public function __construct(int $max_characters, int $max_media_attachments, int $characters_reserved_per_url)
{
- $this->max_characters = $max_characters;
+ $this->max_characters = $max_characters;
+ $this->max_media_attachments = $max_media_attachments;
+ $this->characters_reserved_per_url = $characters_reserved_per_url;
}
}