]> git.mxchange.org Git - friendica.git/blobdiff - include/conversation.php
Improve post direction display
[friendica.git] / include / conversation.php
index 447874584697bfe2e675fe630767cc2a68059129..6fcdd6581281a55955fc53b1ae6185a28772c103 100644 (file)
@@ -711,21 +711,29 @@ function conversation_fetch_comments($thread_items, $pinned) {
        $parentlines = [];
        $lineno = 0;
        $direction = [];
+       $actor = [];
        $received = '';
 
        while ($row = Item::fetch($thread_items)) {
-               if (($row['verb'] == Activity::ANNOUNCE) && ($row['thr-parent'] == $row['parent-uri'])
-                       && ($row['received'] > $received) && Contact::isSharing($row['author-id'], $row['uid'])) {
+               if (!empty($parentlines) && ($row['verb'] == Activity::ANNOUNCE)
+                       && ($row['thr-parent'] == $row['parent-uri']) && ($row['received'] > $received)
+                       && Contact::isSharing($row['author-id'], $row['uid'])) {
                        $direction = ['direction' => 3, 'title' => DI::l10n()->t('%s reshared this.', $row['author-name'])];
+                       $actor = ['link' => $row['author-link'], 'avatar' => $row['author-avatar'], 'name' => $row['author-name']];
                        $received = $row['received'];
                }
 
-               if (empty($direction) && ($row['gravity'] == GRAVITY_COMMENT) && Contact::isSharing($row['author-id'], $row['uid'])) {
-                       $direction = ['direction' => 2, 'title' => DI::l10n()->t('%s commented this.', $row['author-name'])];
+               if (!empty($parentlines) && empty($direction) && ($row['gravity'] == GRAVITY_COMMENT)
+                       && Contact::isSharing($row['author-id'], $row['uid'])) {
+                       $direction = ['direction' => 5, 'title' => DI::l10n()->t('%s commented on this.', $row['author-name'])];
                }
 
                if (($row['gravity'] == GRAVITY_PARENT) && !$row['origin'] && ($row['author-id'] == $row['owner-id'])
                        && !Contact::isSharing($row['author-id'], $row['uid'])) {
+                       if ($row['post-type'] == Item::PT_TAG) {
+                               $row['direction'] = ['direction' => 4, 'title' => DI::l10n()->t('Tagged')];
+                       }
+               
                        $parentlines[] = $lineno;
                }
 
@@ -742,6 +750,11 @@ function conversation_fetch_comments($thread_items, $pinned) {
        if (!empty($direction)) {
                foreach ($parentlines as $line) {
                        $comments[$line]['direction'] = $direction;
+                       if (!empty($actor) && DI::pConfig()->get(local_user(), 'system', 'display_resharer')  ) {
+                               $comments[$line]['owner-link'] = $actor['link'];
+                               $comments[$line]['owner-avatar'] = $actor['avatar'];
+                               $comments[$line]['owner-name'] = $actor['name'];
+                       }
                }
        }
        return $comments;
@@ -808,7 +821,7 @@ function conversation_fetch_items(array $parent, array $items, array $condition,
                $condition[0] .= " AND NOT `author`.`hidden`";
        }
 
-       $thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity']), $condition, $params);
+       $thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity', 'post-type']), $condition, $params);
 
        $comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false);