Merge pull request #12971 from MrPetovan/bug/12970-FriendicaExtension
Account for null title when instantiating FriendicaExtension in Factory\Api\Mastodon\Status
This commit is contained in:
commit
9823b06630
2 changed files with 26 additions and 22 deletions
|
@ -39,6 +39,7 @@ use Friendica\Object\Api\Mastodon\Status\FriendicaExtension;
|
||||||
use Friendica\Object\Api\Mastodon\Status\FriendicaVisibility;
|
use Friendica\Object\Api\Mastodon\Status\FriendicaVisibility;
|
||||||
use Friendica\Protocol\Activity;
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Protocol\ActivityPub;
|
use Friendica\Protocol\ActivityPub;
|
||||||
|
use Friendica\Util\ACLFormatter;
|
||||||
use ImagickException;
|
use ImagickException;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
@ -62,6 +63,8 @@ class Status extends BaseFactory
|
||||||
private $mstdnPollFactory;
|
private $mstdnPollFactory;
|
||||||
/** @var ContentItem */
|
/** @var ContentItem */
|
||||||
private $contentItem;
|
private $contentItem;
|
||||||
|
/** @var ACLFormatter */
|
||||||
|
private $aclFormatter;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
LoggerInterface $logger,
|
LoggerInterface $logger,
|
||||||
|
@ -73,7 +76,8 @@ class Status extends BaseFactory
|
||||||
Attachment $mstdnAttachmentFactory,
|
Attachment $mstdnAttachmentFactory,
|
||||||
Error $mstdnErrorFactory,
|
Error $mstdnErrorFactory,
|
||||||
Poll $mstdnPollFactory,
|
Poll $mstdnPollFactory,
|
||||||
ContentItem $contentItem
|
ContentItem $contentItem,
|
||||||
|
ACLFormatter $aclFormatter
|
||||||
) {
|
) {
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
$this->dba = $dba;
|
$this->dba = $dba;
|
||||||
|
@ -85,6 +89,7 @@ class Status extends BaseFactory
|
||||||
$this->mstdnErrorFactory = $mstdnErrorFactory;
|
$this->mstdnErrorFactory = $mstdnErrorFactory;
|
||||||
$this->mstdnPollFactory = $mstdnPollFactory;
|
$this->mstdnPollFactory = $mstdnPollFactory;
|
||||||
$this->contentItem = $contentItem;
|
$this->contentItem = $contentItem;
|
||||||
|
$this->aclFormatter = $aclFormatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -169,7 +174,7 @@ class Status extends BaseFactory
|
||||||
$count_dislike
|
$count_dislike
|
||||||
);
|
);
|
||||||
|
|
||||||
$origin_like = ($count_like == 0) ? false : Post::exists([
|
$origin_like = $count_like > 0 && Post::exists([
|
||||||
'thr-parent-id' => $uriId,
|
'thr-parent-id' => $uriId,
|
||||||
'uid' => $uid,
|
'uid' => $uid,
|
||||||
'origin' => true,
|
'origin' => true,
|
||||||
|
@ -177,7 +182,7 @@ class Status extends BaseFactory
|
||||||
'vid' => Verb::getID(Activity::LIKE),
|
'vid' => Verb::getID(Activity::LIKE),
|
||||||
'deleted' => false
|
'deleted' => false
|
||||||
]);
|
]);
|
||||||
$origin_dislike = ($count_dislike == 0) ? false : Post::exists([
|
$origin_dislike = $count_dislike > 0 && Post::exists([
|
||||||
'thr-parent-id' => $uriId,
|
'thr-parent-id' => $uriId,
|
||||||
'uid' => $uid,
|
'uid' => $uid,
|
||||||
'origin' => true,
|
'origin' => true,
|
||||||
|
@ -185,7 +190,7 @@ class Status extends BaseFactory
|
||||||
'vid' => Verb::getID(Activity::DISLIKE),
|
'vid' => Verb::getID(Activity::DISLIKE),
|
||||||
'deleted' => false
|
'deleted' => false
|
||||||
]);
|
]);
|
||||||
$origin_announce = ($count_announce == 0) ? false : Post::exists([
|
$origin_announce = $count_announce > 0 && (Post::exists([
|
||||||
'thr-parent-id' => $uriId,
|
'thr-parent-id' => $uriId,
|
||||||
'uid' => $uid,
|
'uid' => $uid,
|
||||||
'origin' => true,
|
'origin' => true,
|
||||||
|
@ -194,16 +199,16 @@ class Status extends BaseFactory
|
||||||
'deleted' => false
|
'deleted' => false
|
||||||
]) || Post::exists([
|
]) || Post::exists([
|
||||||
'quote-uri-id' => $uriId,
|
'quote-uri-id' => $uriId,
|
||||||
'uid' => $uid,
|
'uid' => $uid,
|
||||||
'origin' => true,
|
'origin' => true,
|
||||||
'body' => '',
|
'body' => '',
|
||||||
'deleted' => false
|
'deleted' => false
|
||||||
]);
|
]));
|
||||||
$userAttributes = new \Friendica\Object\Api\Mastodon\Status\UserAttributes(
|
$userAttributes = new \Friendica\Object\Api\Mastodon\Status\UserAttributes(
|
||||||
$origin_like,
|
$origin_like,
|
||||||
$origin_announce,
|
$origin_announce,
|
||||||
Post\ThreadUser::getIgnored($uriId, $uid),
|
Post\ThreadUser::getIgnored($uriId, $uid),
|
||||||
(bool)($item['starred'] && ($item['gravity'] == Item::GRAVITY_PARENT)),
|
$item['starred'] && $item['gravity'] == Item::GRAVITY_PARENT,
|
||||||
$item['featured']
|
$item['featured']
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -300,10 +305,9 @@ class Status extends BaseFactory
|
||||||
$in_reply = [];
|
$in_reply = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$aclFormatter = DI::aclFormatter();
|
|
||||||
$delivery_data = $uid != $item['uid'] ? null : new FriendicaDeliveryData($item['delivery_queue_count'], $item['delivery_queue_done'], $item['delivery_queue_failed']);
|
$delivery_data = $uid != $item['uid'] ? null : new FriendicaDeliveryData($item['delivery_queue_count'], $item['delivery_queue_done'], $item['delivery_queue_failed']);
|
||||||
$visibility_data = $uid != $item['uid'] ? null : new FriendicaVisibility($aclFormatter->expand($item['allow_cid']), $aclFormatter->expand($item['deny_cid']), $aclFormatter->expand($item['allow_gid']), $aclFormatter->expand($item['deny_gid']));
|
$visibility_data = $uid != $item['uid'] ? null : new FriendicaVisibility($this->aclFormatter->expand($item['allow_cid']), $this->aclFormatter->expand($item['deny_cid']), $this->aclFormatter->expand($item['allow_gid']), $this->aclFormatter->expand($item['deny_gid']));
|
||||||
$friendica = new FriendicaExtension($item['title'], $item['changed'], $item['commented'], $item['received'], $counts->dislikes, $origin_dislike, $delivery_data, $visibility_data);
|
$friendica = new FriendicaExtension($item['title'] ?? '', $item['changed'], $item['commented'], $item['received'], $counts->dislikes, $origin_dislike, $delivery_data, $visibility_data);
|
||||||
|
|
||||||
return new \Friendica\Object\Api\Mastodon\Status($item, $account, $counts, $userAttributes, $sensitive, $application, $mentions, $tags, $card, $attachments, $in_reply, $reshare, $friendica, $quote, $poll);
|
return new \Friendica\Object\Api\Mastodon\Status($item, $account, $counts, $userAttributes, $sensitive, $application, $mentions, $tags, $card, $attachments, $in_reply, $reshare, $friendica, $quote, $poll);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,15 +62,15 @@ class FriendicaExtension extends BaseDataTransferObject
|
||||||
/**
|
/**
|
||||||
* Creates a FriendicaExtension object
|
* Creates a FriendicaExtension object
|
||||||
*
|
*
|
||||||
* @param string $title
|
* @param string $title
|
||||||
* @param string|null $changed_at
|
* @param ?string $changed_at
|
||||||
* @param string|null $commented_at
|
* @param ?string $commented_at
|
||||||
* @param string|null $edited_at
|
* @param ?string $received_at
|
||||||
* @param string|null $received_at
|
* @param int $dislikes_count
|
||||||
* @param int $dislikes_count
|
* @param bool $disliked
|
||||||
* @param bool $disliked
|
* @param ?FriendicaDeliveryData $delivery_data
|
||||||
* @param FriendicaDeliveryData|null $delivery_data
|
* @param ?FriendicaVisibility $visibility
|
||||||
* @param FriendicaVisibility|null $visibility
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $title,
|
string $title,
|
||||||
|
|
Loading…
Reference in a new issue