X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FObject%2FPost.php;h=3c01028292d0cd2c2ecabf95c2290bf6634dd39a;hb=e3692c01053d4714292449d1170ef2d60ad575d7;hp=45104130081d34c8c0cbefcfa9565d96dccdeb17;hpb=ba1bdc69208a4deee39dd54dda11b730448643dc;p=friendica.git diff --git a/src/Object/Post.php b/src/Object/Post.php index 4510413008..3c01028292 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -29,10 +29,10 @@ use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\Session; -use Friendica\Database\DBA; 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; @@ -124,8 +124,8 @@ class Post /** * Fetch the privacy of the post * - * @param array $item - * @return string + * @param array $item + * @return string */ private function fetchPrivacy(array $item):string { @@ -249,7 +249,7 @@ class Post ]; } - if (!$item['self']) { + if (!$item['self'] && local_user()) { $block = [ 'blocking' => true, 'block' => DI::l10n()->t('Block %s', $item['author-name']), @@ -445,6 +445,33 @@ class Post $languages = [DI::l10n()->t('Languages'), Item::getLanguageMessage($item)]; } + if (in_array($item['private'], [Item::PUBLIC, Item::UNLISTED]) && in_array($item['network'], Protocol::FEDERATED)) { + $browsershare = [DI::l10n()->t('Share via ...'), DI::l10n()->t('Share via external services')]; + } else { + $browsershare = null; + } + + if (in_array($item['network'], [Protocol::FEED, Protocol::MAIL])) { + $owner_avatar = $author_avatar = $item['contact-id']; + $owner_updated = $author_updated = ''; + $owner_thumb = $author_thumb = $item['contact-avatar']; + } else { + $owner_avatar = $item['owner-id']; + $owner_updated = $item['owner-updated']; + $owner_thumb = $item['owner-avatar']; + $author_avatar = $item['author-id']; + $author_updated = $item['author-updated']; + $author_thumb = $item['author-avatar']; + } + + if (empty($owner_thumb) || Photo::isPhotoURI($owner_thumb)) { + $owner_thumb = Contact::getAvatarUrlForId($owner_avatar, Proxy::SIZE_THUMB, $owner_updated); + } + + if (empty($author_thumb) || Photo::isPhotoURI($author_thumb)) { + $author_thumb = Contact::getAvatarUrlForId($author_avatar, Proxy::SIZE_THUMB, $author_updated); + } + $tmp_item = [ 'template' => $this->getTemplate(), 'type' => implode("", array_slice(explode("/", $item['verb']), -1)), @@ -476,7 +503,7 @@ class Post 'profile_url' => $profile_link, 'name' => $profile_name, 'item_photo_menu_html' => DI::contentItem()->photoMenu($item, $formSecurityToken), - 'thumb' => DI::baseUrl()->remove(Contact::getAvatarUrlForUrl($item['author-link'], $item['uid'], Proxy::SIZE_THUMB)), + 'thumb' => DI::baseUrl()->remove($author_thumb), 'osparkle' => $osparkle, 'sparkle' => $sparkle, 'title' => $title, @@ -493,10 +520,10 @@ class Post 'shiny' => $shiny, 'owner_self' => $item['author-link'] == Session::get('my_url'), 'owner_url' => $this->getOwnerUrl(), - 'owner_photo' => DI::baseUrl()->remove(Contact::getAvatarUrlForUrl($item['owner-link'], $item['uid'], Proxy::SIZE_THUMB)), + 'owner_photo' => DI::baseUrl()->remove($owner_thumb), 'owner_name' => $this->getOwnerName(), 'plink' => Item::getPlink($item), - 'browsershare' => DI::l10n()->t('Share'), + 'browsershare' => $browsershare, 'edpost' => $edpost, 'ispinned' => $ispinned, 'pin' => $pin, @@ -523,8 +550,8 @@ class Post 'thread_level' => $thread_level, 'edited' => $edited, 'network' => $item["network"], - 'network_name' => ContactSelector::networkToName($item['author-network'], $item['author-link'], $item['network']), - 'network_icon' => ContactSelector::networkToIcon($item['network'], $item['author-link']), + 'network_name' => ContactSelector::networkToName($item['author-network'], $item['author-link'], $item['network'], $item['author-gsid']), + 'network_icon' => ContactSelector::networkToIcon($item['network'], $item['author-link'], $item['author-gsid']), 'received' => $item['received'], 'commented' => $item['commented'], 'created_date' => $item['created'], @@ -892,12 +919,7 @@ class Post } $owner = User::getOwnerDataById($a->getLoggedInUserId()); - - $item = PostModel::selectFirst(['author-addr', 'uri-id', 'network', 'gravity', 'content-warning'], ['id' => $this->getId()]); - if (!DBA::isResult($item) || empty($item['author-addr'])) { - // Should not happen - return ''; - } + $item = $this->getData(); if (!empty($item['content-warning']) && Feature::isEnabled(local_user(), 'add_abstract')) { $text = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $item['content-warning'] . "[/abstract]\n"; @@ -961,7 +983,7 @@ class Post $uid = $conv->getProfileOwner(); $parent_uid = $this->getDataValue('uid'); - $contact = Contact::getById($a->getContactId()); + $owner = User::getOwnerDataById($a->getLoggedInUserId()); $default_text = $this->getDefaultText(); @@ -980,9 +1002,9 @@ class Post '$qcomment' => $qcomment, '$default' => $default_text, '$profile_uid' => $uid, - '$mylink' => DI::baseUrl()->remove($contact['url'] ?? ''), + '$mylink' => DI::baseUrl()->remove($owner['url'] ?? ''), '$mytitle' => DI::l10n()->t('This is you'), - '$myphoto' => DI::baseUrl()->remove($contact['thumb'] ?? ''), + '$myphoto' => DI::baseUrl()->remove($owner['thumb'] ?? ''), '$comment' => DI::l10n()->t('Comment'), '$submit' => DI::l10n()->t('Submit'), '$loading' => DI::l10n()->t('Loading...'),