]> git.mxchange.org Git - friendica.git/blobdiff - src/Object/Post.php
Merge pull request #11369 from annando/empty-item
[friendica.git] / src / Object / Post.php
index bbd1e9ce1c037bb73dec3e9435af5020f115a6ea..4e0d8d238923d37b77d0cf1e2dab14191d441060 100644 (file)
@@ -389,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')) {
@@ -891,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']) {