X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FObject%2FPost.php;h=8d7ff128dc3911c172b7e3f7e80b0661f784795e;hb=c7f1c30f89100732b966d40a9767912febdfe432;hp=15a1350795f6459f0036e95853e51345cb14a12d;hpb=1edb7b6464db7d12d2582cb923ed9760db75efb7;p=friendica.git diff --git a/src/Object/Post.php b/src/Object/Post.php index 15a1350795..8d7ff128dc 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -31,17 +31,15 @@ use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Item; -use Friendica\Model\Photo; use Friendica\Model\Post as PostModel; use Friendica\Model\Tag; use Friendica\Model\User; use Friendica\Protocol\Activity; use Friendica\Util\Crypto; use Friendica\Util\DateTimeFormat; -use Friendica\Util\Network; -use Friendica\Util\Proxy; use Friendica\Util\Strings; use Friendica\Util\Temporal; +use GuzzleHttp\Psr7\Uri; use InvalidArgumentException; /** @@ -158,15 +156,16 @@ class Post /** * Get data in a form usable by a conversation template * - * @param array $conv_responses conversation responses - * @param string $formSecurityToken A security Token to avoid CSF attacks - * @param integer $thread_level default = 1 + * @param array $conv_responses conversation responses + * @param string $formSecurityToken A security Token to avoid CSF attacks + * @param integer $thread_level default = 1 + * @param array $thread_parent Array of parent guid and parent author names * * @return mixed The data requested on success, false on failure * @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \ImagickException */ - public function getTemplateData(array $conv_responses, string $formSecurityToken, int $thread_level = 1) + public function getTemplateData(array $conv_responses, string $formSecurityToken, int $thread_level = 1, array $thread_parent = []) { $item = $this->getData(); $edited = false; @@ -284,9 +283,10 @@ class Post 'label' => DI::l10n()->t('Report post'), 'href' => 'moderation/report/create?' . http_build_query(['cid' => $item['author-id'], 'uri-ids' => [$item['uri-id']]]), ]; - if (!Network::isLocalLink($item['plink'])) { + $authorBaseUri = new Uri($item['author-baseurl'] ?? ''); + if ($authorBaseUri->getHost() && !DI::baseUrl()->isLocalUrl($authorBaseUri)) { $ignoreServer = [ - 'label' => DI::l10n()->t("Ignore %s's server", $item['author-name']), + 'label' => DI::l10n()->t("Ignore %s server", $authorBaseUri->getHost()), ]; } } @@ -497,7 +497,15 @@ class Post $browsershare = null; } + $parent_guid = $thread_parent[$item['thr-parent-id']]['guid'] ?? ''; + $parent_username = $thread_parent[$item['thr-parent-id']]['name'] ?? ''; + $parent_unknown = $parent_username ? '' : DI::l10n()->t('Unknown parent'); + $tmp_item = [ + 'parentguid' => $parent_guid, + 'inreplyto' => DI::l10n()->t('in reply to %s', $parent_username), + 'isunknown' => $parent_unknown, + 'isunknown_label' => DI::l10n()->t('Parent is probably private or not federated.'), 'template' => $this->getTemplate(), 'type' => implode('', array_slice(explode('/', $item['verb']), -1)), 'comment_firstcollapsed' => false, @@ -610,8 +618,10 @@ class Post $children = $this->getChildren(); $nb_children = count($children); if ($nb_children > 0) { + $thread_parent[$item['uri-id']] = ['guid' => $item['guid'], 'name' => $item['author-name']]; foreach ($children as $child) { - $result['children'][] = $child->getTemplateData($conv_responses, $formSecurityToken, $thread_level + 1); + $thread_parent[$child->getDataValue('uri-id')] = ['guid' => $child->getDataValue('guid'), 'name' => $child->getDataValue('author-name')]; + $result['children'][] = $child->getTemplateData($conv_responses, $formSecurityToken, $thread_level + 1, $thread_parent); } // Collapse