]> git.mxchange.org Git - friendica.git/commitdiff
Issue 14433: Display reshared content in feeds
authorMichael <heluecht@pirati.ca>
Sun, 9 Mar 2025 07:52:58 +0000 (07:52 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 10 Mar 2025 05:15:43 +0000 (05:15 +0000)
src/Protocol/Feed.php

index 2f9be305f15a2e9a508a34fc91d174b67579b6f7..6a2f5d42ddf4428c099a5d48ed64750928e6304f 100644 (file)
@@ -1040,34 +1040,44 @@ class Feed
                $authorid   = Contact::getIdForURL($owner['url']);
 
                $condition = [
-                       "`uid` = ? AND `received` > ? AND NOT `deleted` AND `gravity` IN (?, ?)
-                       AND `private` != ? AND `visible` AND `wall` AND `parent-network` IN (?, ?, ?)",
+                       "`uid` = ? AND `received` > ? AND NOT `deleted`
+                       AND ((`gravity` IN (?, ?) AND `wall`) OR (`gravity` = ? AND `verb` = ?))
+                       AND `origin` AND `private` != ? AND `visible` AND `parent-network` IN (?, ?, ?)
+                       AND `author-id` = ?",
                        $owner['uid'], $check_date, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT,
-                       Item::PRIVATE, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA
+                       Item::GRAVITY_ACTIVITY, Activity::ANNOUNCE,
+                       Item::PRIVATE, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA,
+                       $authorid
                ];
 
                if ($filter === 'comments') {
-                       $condition[0] .= " AND `gravity` = ? ";
-                       $condition[] = Item::GRAVITY_COMMENT;
-               }
-
-               if ($owner['account-type'] != User::ACCOUNT_TYPE_COMMUNITY) {
-                       $condition[0] .= " AND `contact-id` = ? AND `author-id` = ?";
-                       $condition[] = $owner['id'];
-                       $condition[] = $authorid;
+                       $condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_COMMENT]);
+               } elseif ($filter === 'posts') {
+                       $condition = DBA::mergeConditions($condition, ['gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_ACTIVITY]]);
                }
 
                $params = ['order' => ['received' => true], 'limit' => $max_items];
 
-               if ($filter === 'posts') {
-                       $ret = Post::selectOriginThread(Item::DELIVER_FIELDLIST, $condition, $params);
-               } else {
-                       $ret = Post::selectOrigin(Item::DELIVER_FIELDLIST, $condition, $params);
-               }
+               $ret = Post::selectOrigin(Item::DELIVER_FIELDLIST, $condition, $params);
 
                $items = Post::toArray($ret);
 
-               $doc               = new DOMDocument('1.0', 'utf-8');
+               $reshares = [];
+               foreach ($items as $index => $item) {
+                       if ($item['verb'] == Activity::ANNOUNCE) {
+                               $reshares[$item['thr-parent-id']] = $index;
+                       }
+               }
+
+               if (!empty($reshares)) {
+                       $posts = Post::selectToArray(Item::DELIVER_FIELDLIST, ['uri-id' => array_keys($reshares), 'uid' => $owner['uid']]);
+                       foreach ($posts as $post) {
+                               $items[$reshares[$post['uri-id']]] = $post;
+                       }
+               }
+
+               $doc = new DOMDocument('1.0', 'utf-8');
+
                $doc->formatOutput = true;
 
                $root = self::addHeader($doc, $owner, $filter);