X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FObject%2FPost.php;h=4e0d8d238923d37b77d0cf1e2dab14191d441060;hb=2438eb78dd0f8014a947c1df1cf5b862e4ac285e;hp=17303bd62d7540abd84de44e875fbf9da7d4380c;hpb=50580fd04cf7639905ff77dd8a58910c9c8c5a52;p=friendica.git diff --git a/src/Object/Post.php b/src/Object/Post.php index 17303bd62d..4e0d8d2389 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -121,6 +121,29 @@ class Post } } + /** + * Fetch the privacy of the post + * + * @param array $item + * @return string + */ + private function fetchPrivacy(array $item):string + { + switch ($item['private']) { + case Item::PRIVATE: + $output = DI::l10n()->t('Private Message'); + break; + case Item::PUBLIC: + $output = DI::l10n()->t('Public Message'); + break; + case Item::UNLISTED: + $output = DI::l10n()->t('Unlisted Message'); + break; + } + + return $output; + } + /** * Get data in a form usable by a conversation template * @@ -170,12 +193,9 @@ class Post $conv = $this->getThread(); - $lock = ((($item['private'] == Item::PRIVATE) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) - || strlen($item['deny_cid']) || strlen($item['deny_gid'])))) - ? DI::l10n()->t('Private Message') - : false); - - $connector = !$item['global'] ? DI::l10n()->t('Connector Message') : false; + $privacy = $this->fetchPrivacy($item); + $lock = ($item['private'] == Item::PRIVATE) ? $privacy : false; + $connector = !in_array($item['network'], Protocol::NATIVE_SUPPORT) ? DI::l10n()->t('Connector Message') : false; $shareable = in_array($conv->getProfileOwner(), [0, local_user()]) && $item['private'] != Item::PRIVATE; $announceable = $shareable && in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::TWITTER]); @@ -369,10 +389,12 @@ class Post list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item, local_user()); - if (!empty($item['content-warning']) && DI::pConfig()->get(local_user(), 'system', 'disable_cw', false)) { + if (!empty($item['title'])) { + $title = $item['title']; + } elseif (!empty($item['content-warning']) && DI::pConfig()->get(local_user(), 'system', 'disable_cw', false)) { $title = ucfirst($item['content-warning']); } else { - $title = $item['title']; + $title = ''; } if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) { @@ -463,6 +485,8 @@ class Post 'app' => $item['app'], 'created' => $ago, 'lock' => $lock, + 'private' => $item['private'], + 'privacy' => $privacy, 'connector' => $connector, 'location_html' => $location_html, 'indent' => $indent, @@ -869,22 +893,26 @@ class Post $owner = User::getOwnerDataById($a->getLoggedInUserId()); - if (!Feature::isEnabled(local_user(), 'explicit_mentions')) { - return ''; - } - - $item = PostModel::selectFirst(['author-addr', 'uri-id', 'network', 'gravity'], ['id' => $this->getId()]); + $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 ''; } - if (($item['author-addr'] != $owner['addr']) && (($item['gravity'] != GRAVITY_PARENT) || !in_array($item['network'], [Protocol::DIASPORA]))) { - $text = '@' . $item['author-addr'] . ' '; + if (!empty($item['content-warning']) && Feature::isEnabled(local_user(), 'add_abstract')) { + $text = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $item['content-warning'] . "[/abstract]\n"; } else { $text = ''; } + if (!Feature::isEnabled(local_user(), 'explicit_mentions')) { + return $text; + } + + if (($item['author-addr'] != $owner['addr']) && (($item['gravity'] != GRAVITY_PARENT) || !in_array($item['network'], [Protocol::DIASPORA]))) { + $text .= '@' . $item['author-addr'] . ' '; + } + $terms = Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]); foreach ($terms as $term) { if (!$term['url']) {