Merge branch 'develop' into mastodon-timeline-temporal-paging

This commit is contained in:
Hank Grabowski 2023-02-27 20:20:40 -05:00
commit 6ffd3a3f8c
45 changed files with 798 additions and 138 deletions

View file

@ -84,14 +84,14 @@ class Instance extends BaseDataTransferObject
{
$register_policy = intval($config->get('config', 'register_policy'));
$this->uri = $baseUrl;
$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 = null; // Not supported
$this->stats = new Stats($config, $database);
$this->thumbnail = $baseUrl . 'images/friendica-banner.jpg';
$this->thumbnail = $baseUrl . '/images/friendica-banner.jpg';
$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);

View file

@ -39,9 +39,9 @@ class Contact extends BaseDataTransferObject
/**
* @param string $email
* @param Account $account
* @param Account|null $account
*/
public function __construct(string $email, Account $account)
public function __construct(string $email, ?Account $account)
{
$this->email = $email;
$this->account = $account;

View file

@ -31,13 +31,13 @@ use Friendica\BaseDataTransferObject;
class UserStats extends BaseDataTransferObject
{
/** @var int */
protected $active_monthly = 0;
protected $active_month = 0;
/**
* @param $active_monthly
* @param int $active_month
*/
public function __construct($active_monthly)
public function __construct(int $active_month)
{
$this->active_monthly = $active_monthly;
$this->active_month = $active_month;
}
}

View file

@ -105,7 +105,7 @@ class Status extends BaseDataTransferObject
* @param array $item
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function __construct(array $item, Account $account, Counts $counts, UserAttributes $userAttributes, bool $sensitive, Application $application, array $mentions, array $tags, Card $card, array $attachments, array $in_reply, array $reblog, array $quote = null, array $poll = null)
public function __construct(array $item, Account $account, Counts $counts, UserAttributes $userAttributes, bool $sensitive, Application $application, array $mentions, array $tags, Card $card, array $attachments, array $in_reply, array $reblog, FriendicaExtension $friendica, array $quote = null, array $poll = null)
{
$this->id = (string)$item['uri-id'];
$this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::JSON);
@ -151,7 +151,7 @@ class Status extends BaseDataTransferObject
$this->emojis = [];
$this->card = $card->toArray() ?: null;
$this->poll = $poll;
$this->friendica = new FriendicaExtension($item['title'], $counts->dislikes);
$this->friendica = $friendica;
}
/**

View file

@ -0,0 +1,55 @@
<?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\Status;
use Friendica\BaseDataTransferObject;
/**
* Class FriendicaDeliveryData
*
* Additional fields on Mastodon Statuses for storing Friendica delivery data
*
* @see https://docs.joinmastodon.org/entities/status
*/
class FriendicaDeliveryData extends BaseDataTransferObject
{
/** @var int|null */
protected $delivery_queue_count;
/** @var int|null */
protected $delivery_queue_done;
/** @var int|null */
protected $delivery_queue_failed;
/**
* Creates a FriendicaDeliveryData object
*
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function __construct(?int $delivery_queue_count, ?int $delivery_queue_done, ?int $delivery_queue_failed)
{
$this->delivery_queue_count = $delivery_queue_count;
$this->delivery_queue_done = $delivery_queue_done;
$this->delivery_queue_failed = $delivery_queue_failed;
}
}

View file

@ -35,6 +35,8 @@ class FriendicaExtension extends BaseDataTransferObject
/** @var string */
protected $title;
/** @var FriendicaDeliveryData */
protected $delivery_data;
/** @var int */
protected $dislikes_count;
@ -42,11 +44,13 @@ class FriendicaExtension extends BaseDataTransferObject
* Creates a status count object
*
* @param string $title
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @param int $dislikes_count
* @param FriendicaDeliveryData $delivery_data
*/
public function __construct(string $title, int $dislikes_count)
public function __construct(string $title, int $dislikes_count, FriendicaDeliveryData $delivery_data)
{
$this->title = $title;
$this->delivery_data = $delivery_data;
$this->dislikes_count = $dislikes_count;
}
}