friendica/src/Object/Api/Mastodon/Instance.php

98 lines
3.4 KiB
PHP
Raw Normal View History

2019-12-11 07:51:59 +01:00
<?php
2020-02-09 15:45:36 +01:00
/**
* @copyright Copyright (C) 2010-2024, the Friendica project
2020-02-09 15:45:36 +01:00
*
* @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/>.
*
*/
2019-12-11 07:51:59 +01:00
namespace Friendica\Object\Api\Mastodon;
2019-12-11 07:51:59 +01:00
use Friendica\App;
use Friendica\App\BaseURL;
use Friendica\BaseDataTransferObject;
use Friendica\Contact\Header;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Database\Database;
2019-12-11 07:51:59 +01:00
use Friendica\Model\User;
use Friendica\Module\Register;
use Friendica\Object\Api\Mastodon\InstanceV2\Configuration;
2019-12-11 07:51:59 +01:00
/**
* Class Instance
2019-12-11 07:51:59 +01:00
*
* @see https://docs.joinmastodon.org/entities/V1_Instance/
2019-12-11 07:51:59 +01:00
*/
class Instance extends BaseDataTransferObject
2019-12-11 07:51:59 +01:00
{
/** @var string (URL) */
protected $uri;
2019-12-11 07:51:59 +01:00
/** @var string */
protected $title;
2019-12-11 07:51:59 +01:00
/** @var string */
2021-06-10 21:10:33 +02:00
protected $short_description;
/** @var string */
protected $description;
2019-12-11 07:51:59 +01:00
/** @var string */
protected $email;
2019-12-11 07:51:59 +01:00
/** @var string */
protected $version;
2019-12-11 07:51:59 +01:00
/** @var array */
protected $urls;
2019-12-11 07:51:59 +01:00
/** @var Stats */
protected $stats;
/** @var string|null This is meant as a server banner, default Mastodon "thumbnail" is 1600×620px */
protected $thumbnail = null;
2019-12-11 07:51:59 +01:00
/** @var array */
protected $languages;
2019-12-11 07:51:59 +01:00
/** @var int */
protected $max_toot_chars;
2019-12-11 07:51:59 +01:00
/** @var bool */
protected $registrations;
2019-12-11 07:51:59 +01:00
/** @var bool */
protected $approval_required;
2021-06-10 21:10:33 +02:00
/** @var bool */
protected $invites_enabled;
/** @var Configuration */
protected $configuration;
/** @var Account|null */
protected $contact_account = null;
2021-06-10 21:10:33 +02:00
/** @var array */
protected $rules = [];
2019-12-11 07:51:59 +01:00
public function __construct(IManageConfigValues $config, BaseURL $baseUrl, Database $database, Configuration $configuration, ?Account $contact_account, array $rules)
{
$register_policy = Register::getPolicy();
2019-12-11 07:51:59 +01:00
2023-02-27 22:02:59 +01:00
$this->uri = $baseUrl->getHost();
$this->title = $config->get('config', 'sitename');
$this->short_description = $this->description = $config->get('config', 'info');
$this->email = implode(',', User::getAdminEmailList());
$this->version = '2.8.0 (compatible; Friendica ' . App::VERSION . ')';
$this->urls = ['streaming_api' => '']; // Not supported
$this->stats = new Stats($config, $database);
$this->thumbnail = $baseUrl . (new Header($config))->getMastodonBannerPath();
$this->languages = [$config->get('system', 'language')];
$this->max_toot_chars = (int)$config->get('config', 'api_import_size', $config->get('config', 'max_import_size'));
$this->registrations = ($register_policy !== Register::CLOSED);
$this->approval_required = ($register_policy === Register::APPROVE);
$this->invites_enabled = false;
$this->configuration = $configuration;
$this->contact_account = $contact_account ?? [];
$this->rules = $rules;
2019-12-11 07:51:59 +01:00
}
}