mirror of
https://github.com/friendica/friendica
synced 2025-04-26 00:30:12 +00:00
Issue 12530: Align the instance endpoint to the latest changes
This commit is contained in:
parent
02afde3eec
commit
199ac64202
9 changed files with 152 additions and 8 deletions
|
@ -29,7 +29,10 @@ use Friendica\Database\Database;
|
|||
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;
|
||||
|
||||
/**
|
||||
|
@ -59,6 +62,30 @@ class Instance extends BaseApi
|
|||
*/
|
||||
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(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,13 +119,21 @@ class InstanceV2 extends BaseApi
|
|||
'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(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue