]> git.mxchange.org Git - friendica.git/blobdiff - src/Object/Post.php
Merge pull request #8835 from tobiasd/20200701-lng
[friendica.git] / src / Object / Post.php
index 1c1f85e2a502bfa0677a31cd8686a0735992a37b..0a68bbbe2b7dfb11bc167c88e6c8161fa1eb2c89 100644 (file)
@@ -33,7 +33,7 @@ use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\Item;
-use Friendica\Model\Term;
+use Friendica\Model\Tag;
 use Friendica\Model\User;
 use Friendica\Protocol\Activity;
 use Friendica\Util\Crypto;
@@ -214,7 +214,7 @@ class Post
                        $pinned = DI::l10n()->t('pinned item');
                }
 
-               if ($origin && ($item['id'] != $item['parent']) && ($item['network'] == Protocol::ACTIVITYPUB)) {
+               if ($origin && ($item['gravity'] != GRAVITY_PARENT) && ($item['network'] == Protocol::ACTIVITYPUB)) {
                        // ActivityPub doesn't allow removal of remote comments
                        $delete = DI::l10n()->t('Delete locally');
                } else {
@@ -380,8 +380,11 @@ class Post
                }
 
                // Disable features that aren't available in several networks
-               if ($buttons["dislike"] && !in_array($item["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA])) {
-                       $buttons["dislike"] = false;
+               if (!in_array($item["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA])) {
+                       if ($buttons["dislike"]) {
+                               $buttons["dislike"] = false;
+                       }
+
                        $isevent = false;
                        $tagger = '';
                }
@@ -390,7 +393,7 @@ class Post
                        $buttons["like"] = false;
                }
 
-               $tags = Term::populateTagsFromItem($item);
+               $tags = Tag::populateFromItem($item);
 
                $ago = Temporal::getRelativeDate($item['created']);
                $ago_received = Temporal::getRelativeDate($item['received']);
@@ -406,6 +409,15 @@ class Post
                        $remote_comment = '';
                }
 
+               $direction = [];
+               if (DI::config()->get('debug', 'show_direction')) {
+                       $conversation = DBA::selectFirst('conversation', ['direction'], ['item-uri' => $item['uri']]);
+                       if (!empty($conversation['direction']) && in_array($conversation['direction'], [1, 2])) {
+                               $title = [1 => DI::l10n()->t('Pushed'), 2 => DI::l10n()->t('Pulled')];
+                               $direction = ['direction' => $conversation['direction'], 'title' => $title[$conversation['direction']]];
+                       }
+               }
+
                $tmp_item = [
                        'template'        => $this->getTemplate(),
                        'type'            => implode("", array_slice(explode("/", $item['verb']), -1)),
@@ -482,6 +494,7 @@ class Post
                        'commented'       => $item['commented'],
                        'created_date'    => $item['created'],
                        'return'          => (DI::args()->getCommand()) ? bin2hex(DI::args()->getCommand()) : '',
+                       'direction'       => $direction,
                        'delivery'        => [
                                'queue_count'       => $item['delivery_queue_count'],
                                'queue_done'        => $item['delivery_queue_done'] + $item['delivery_queue_failed'], /// @todo Possibly display it separately in the future
@@ -850,7 +863,7 @@ class Post
                        return '';
                }
 
-               $item = Item::selectFirst(['author-addr'], ['id' => $this->getId()]);
+               $item = Item::selectFirst(['author-addr', 'uri-id'], ['id' => $this->getId()]);
                if (!DBA::isResult($item) || empty($item['author-addr'])) {
                        // Should not happen
                        return '';
@@ -862,7 +875,7 @@ class Post
                        $text = '';
                }
 
-               $terms = Term::tagArrayFromItemId($this->getId(), [Term::MENTION, Term::IMPLICIT_MENTION]);
+               $terms = Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]);
                foreach ($terms as $term) {
                        $profile = Contact::getDetailsByURL($term['url']);
                        if (!empty($profile['addr']) && ((($profile['contact-type'] ?? '') ?: Contact::TYPE_UNKNOWN) != Contact::TYPE_COMMUNITY) &&