]> git.mxchange.org Git - friendica.git/blobdiff - include/conversation.php
Merge remote-tracking branch 'upstream/develop' into relayed-dfrn-dspr
[friendica.git] / include / conversation.php
index 8b658521ed7a4e2a877fadd858121f3496de0b04..f3df8db0152c9e84bc8ea4c10924ae6c460140e6 100644 (file)
@@ -443,7 +443,9 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                if (!$update) {
                        $live_update_div = '<div id="live-community"></div>' . "\r\n"
                                . "<script> var profile_uid = -1; var netargs = '" . substr(DI::args()->getCommand(), 10)
-                               ."/?f='; </script>\r\n";
+                               . '?f='
+                               . (!empty($_GET['no_sharer']) ? '&no_sharer=' . rawurlencode($_GET['no_sharer']) : '')
+                               . "'; </script>\r\n";
                }
        } elseif ($mode === 'contacts') {
                $items = conversation_add_children($items, false, $order, $uid);
@@ -520,10 +522,6 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
 
                                $threadsid++;
 
-                               $owner_url   = '';
-                               $owner_name  = '';
-                               $sparkle     = '';
-
                                // prevent private email from leaking.
                                if ($item['network'] === Protocol::MAIL && local_user() != $item['uid']) {
                                        continue;
@@ -540,6 +538,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                                        'network' => $item['author-network'], 'url' => $item['author-link']];
                                $profile_link = Contact::magicLinkByContact($author);
 
+                               $sparkle = '';
                                if (strpos($profile_link, 'redir/') === 0) {
                                        $sparkle = ' sparkle';
                                }
@@ -562,10 +561,6 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                                        'delete' => DI::l10n()->t('Delete'),
                                ];
 
-                               $star = false;
-                               $isstarred = "unstarred";
-
-                               $lock = false;
                                $likebuttons = [
                                        'like'    => null,
                                        'dislike' => null,
@@ -590,6 +585,10 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                                        'template' => $tpl,
                                        'id' => ($preview ? 'P0' : $item['id']),
                                        'guid' => ($preview ? 'Q0' : $item['guid']),
+                                       'commented' => $item['commented'],
+                                       'received' => $item['received'],
+                                       'created_date' => $item['created'],
+                                       'uriid' => $item['uri-id'],
                                        'network' => $item['network'],
                                        'network_name' => ContactSelector::networkToName($item['author-network'], $item['author-link'], $item['network']),
                                        'network_icon' => ContactSelector::networkToIcon($item['network'], $item['author-link']),
@@ -598,7 +597,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                                        'item_photo_menu_html' => item_photo_menu($item),
                                        'name' => $profile_name,
                                        'sparkle' => $sparkle,
-                                       'lock' => $lock,
+                                       'lock' => false,
                                        'thumb' => DI::baseUrl()->remove($item['author-avatar']),
                                        'title' => $title,
                                        'body_html' => $body_html,
@@ -617,18 +616,18 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                                        'ago' => (($item['app']) ? DI::l10n()->t('%s from %s', Temporal::getRelativeDate($item['created']),$item['app']) : Temporal::getRelativeDate($item['created'])),
                                        'location_html' => $location_html,
                                        'indent' => '',
-                                       'owner_name' => $owner_name,
-                                       'owner_url' => $owner_url,
+                                       'owner_name' => '',
+                                       'owner_url' => '',
                                        'owner_photo' => DI::baseUrl()->remove($item['owner-avatar']),
                                        'plink' => Item::getPlink($item),
                                        'edpost' => false,
-                                       'isstarred' => $isstarred,
-                                       'star' => $star,
+                                       'isstarred' => 'unstarred',
+                                       'star' => false,
                                        'drop' => $drop,
                                        'vote' => $likebuttons,
-                                       'like' => '',
-                                       'dislike' => '',
-                                       'comment' => '',
+                                       'like_html' => '',
+                                       'dislike_html' => '',
+                                       'comment_html' => '',
                                        'conv' => (($preview) ? '' : ['href'=> 'display/'.$item['guid'], 'title'=> DI::l10n()->t('View in context')]),
                                        'previewing' => $previewing,
                                        'wait' => DI::l10n()->t('Please wait'),
@@ -715,30 +714,9 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
  */
 function conversation_fetch_comments($thread_items, $pinned) {
        $comments = [];
-       $parentlines = [];
-       $lineno = 0;
-       $direction = [];
-       $actor = [];
-       $received = '';
 
        while ($row = Item::fetch($thread_items)) {
-               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'])];
-
-                       $author = ['uid' => 0, 'id' => $row['author-id'],
-                               'network' => $row['author-network'], 'url' => $row['author-link']];
-                       $url = '<a href="'. htmlentities(Contact::magicLinkByContact($author)) .'">' . htmlentities($row['author-name']) . '</a>';
-
-                       $actor = ['url' => $url, 'link' => $row['author-link'], 'avatar' => $row['author-avatar'], 'name' => $row['author-name']];
-                       $received = $row['received'];
-               }
-
-               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'])];
-               }
+               $name = $row['causer-contact-type'] == Contact::TYPE_RELAY ? $row['causer-link'] : $row['causer-name'];
 
                switch ($row['post-type']) {
                        case Item::PT_TO:
@@ -760,7 +738,16 @@ function conversation_fetch_comments($thread_items, $pinned) {
                                $row['direction'] = ['direction' => 4, 'title' => DI::l10n()->t('Tagged')];
                                break;
                        case Item::PT_ANNOUNCEMENT:
-                               $row['direction'] = ['direction' => 3, 'title' => DI::l10n()->t('Reshared')];
+                               if (!empty($row['causer-id']) && DI::pConfig()->get(local_user(), 'system', 'display_resharer')) {
+                                       $row['owner-link'] = $row['causer-link'];
+                                       $row['owner-avatar'] = $row['causer-avatar'];
+                                       $row['owner-name'] = $row['causer-name'];
+                               }
+
+                               if (($row['gravity'] == GRAVITY_PARENT) && !empty($row['causer-id'])) {
+                                       $row['reshared'] = DI::l10n()->t('%s reshared this.', '<a href="'. htmlentities(Contact::magicLinkbyId($row['causer-id'])) .'">' . htmlentities($name) . '</a>');
+                               }
+                               $row['direction'] = ['direction' => 3, 'title' => (empty($row['causer-id']) ? DI::l10n()->t('Reshared') : DI::l10n()->t('Reshared by %s', $name))];
                                break;
                        case Item::PT_COMMENT:
                                $row['direction'] = ['direction' => 5, 'title' => DI::l10n()->t('%s is participating in this thread.', $row['author-name'])];
@@ -768,36 +755,26 @@ function conversation_fetch_comments($thread_items, $pinned) {
                        case Item::PT_STORED:
                                $row['direction'] = ['direction' => 8, 'title' => DI::l10n()->t('Stored')];
                                break;
-               }
-
-               if (($row['gravity'] == GRAVITY_PARENT) && !$row['origin'] && ($row['author-id'] == $row['owner-id']) &&
-                       !Contact::isSharing($row['author-id'], $row['uid'])) {
-                       $parentlines[] = $lineno;
-               }
+                       case Item::PT_GLOBAL:
+                               $row['direction'] = ['direction' => 9, 'title' => DI::l10n()->t('Global')];
+                               break;
+                       case Item::PT_RELAY:
+                               $row['direction'] = ['direction' => 10, 'title' => (empty($row['causer-id']) ? DI::l10n()->t('Relayed') : DI::l10n()->t('Relayed by %s.', $name))];
+                               break;
+                       case Item::PT_FETCHED:
+                               $row['direction'] = ['direction' => 2, 'title' => (empty($row['causer-id']) ? DI::l10n()->t('Fetched') : DI::l10n()->t('Fetched because of %s', $name))];
+                               break;
+                       }
 
                if ($row['gravity'] == GRAVITY_PARENT) {
                        $row['pinned'] = $pinned;
                }
 
                $comments[] = $row;
-               $lineno++;
        }
 
        DBA::close($thread_items);
 
-       if (!empty($direction)) {
-               foreach ($parentlines as $line) {
-                       $comments[$line]['direction'] = $direction;
-                       if (!empty($actor)) {
-                               $comments[$line]['reshared'] = DI::l10n()->t('%s reshared this.', $actor['url']);
-                               if (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;
 }
 
@@ -1032,6 +1009,12 @@ function builtin_activity_puller($item, &$conv_responses) {
                                continue;
                        }
 
+                       // Skip when the causer of the parent is the same than the author of the announce
+                       if (($verb == Activity::ANNOUNCE) && Item::exists(['uri' => $item['thr-parent'],
+                               'uid' => $item['uid'], 'causer-id' => $item['author-id'], 'gravity' => GRAVITY_PARENT])) {
+                               continue;
+                       }
+
                        if (!isset($conv_responses[$mode][$item['thr-parent']])) {
                                $conv_responses[$mode][$item['thr-parent']] = 1;
                        } else {