use Friendica\Model\Tag as TagModel;
use Friendica\Model\Verb;
use Friendica\Network\HTTPException;
+use Friendica\Object\Api\Mastodon\Status\FriendicaDeliveryData;
+use Friendica\Object\Api\Mastodon\Status\FriendicaExtension;
use Friendica\Protocol\Activity;
use Friendica\Protocol\ActivityPub;
use ImagickException;
public function createFromUriId(int $uriId, int $uid = 0, bool $display_quote = false, bool $reblog = true, bool $in_reply_status = true): \Friendica\Object\Api\Mastodon\Status
{
$fields = ['uri-id', 'uid', 'author-id', 'causer-id', 'author-uri-id', 'author-link', 'causer-uri-id', 'post-reason', 'starred', 'app', 'title', 'body', 'raw-body', 'content-warning', 'question-id',
- 'created', 'network', 'thr-parent-id', 'parent-author-id', 'language', 'uri', 'plink', 'private', 'vid', 'gravity', 'featured', 'has-media', 'quote-uri-id'];
+ 'created', 'network', 'thr-parent-id', 'parent-author-id', 'language', 'uri', 'plink', 'private', 'vid', 'gravity', 'featured', 'has-media', 'quote-uri-id',
+ 'delivery_queue_count', 'delivery_queue_done','delivery_queue_failed'];
$item = Post::selectFirst($fields, ['uri-id' => $uriId, 'uid' => [0, $uid]], ['order' => ['uid' => true]]);
if (!$item) {
$mail = DBA::selectFirst('mail', ['id'], ['uri-id' => $uriId, 'uid' => $uid]);
$in_reply = [];
}
- return new \Friendica\Object\Api\Mastodon\Status($item, $account, $counts, $userAttributes, $sensitive, $application, $mentions, $tags, $card, $attachments, $in_reply, $reshare, $quote, $poll);
+ $queue_count = $item['delivery_queue_count'];
+ $queue_done = $item['delivery_queue_done'];
+ $queue_failed = $item['delivery_queue_failed'];
+ $delivery_data = new FriendicaDeliveryData($queue_count, $queue_done, $queue_failed);
+ $friendica = new FriendicaExtension($item['title'], $counts->dislikes, $delivery_data);
+
+ return new \Friendica\Object\Api\Mastodon\Status($item, $account, $counts, $userAttributes, $sensitive, $application, $mentions, $tags, $card, $attachments, $in_reply, $reshare, $friendica, $quote, $poll);
}
/**
$attachments = [];
$in_reply = [];
$reshare = [];
+ $friendica = new FriendicaExtension('', 0, new FriendicaDeliveryData(0, 0, 0));
- return new \Friendica\Object\Api\Mastodon\Status($item, $account, $counts, $userAttributes, $sensitive, $application, $mentions, $tags, $card, $attachments, $in_reply, $reshare);
+ return new \Friendica\Object\Api\Mastodon\Status($item, $account, $counts, $userAttributes, $sensitive, $application, $mentions, $tags, $card, $attachments, $in_reply, $reshare, $friendica);
}
}
* @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);
$this->emojis = [];
$this->card = $card->toArray() ?: null;
$this->poll = $poll;
- $this->friendica = new FriendicaExtension($item['title'], $counts->dislikes);
+ $this->friendica = $friendica;
}
/**
--- /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\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 */
+ protected $delivery_queue_count;
+
+ /** @var int */
+ protected $delivery_queue_done;
+
+ /** @var int */
+ 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;
+ }
+}