Merge pull request #14845 from annando/issue-14433

Issue 14433: Display reshared content in feeds
This commit is contained in:
Hypolite Petovan 2025-03-10 10:24:49 -04:00 committed by GitHub
commit 9261b5262c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1040,34 +1040,44 @@ class Feed
$authorid = Contact::getIdForURL($owner['url']); $authorid = Contact::getIdForURL($owner['url']);
$condition = [ $condition = [
"`uid` = ? AND `received` > ? AND NOT `deleted` AND `gravity` IN (?, ?) "`uid` = ? AND `received` > ? AND NOT `deleted`
AND `private` != ? AND `visible` AND `wall` AND `parent-network` IN (?, ?, ?)", 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, $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') { if ($filter === 'comments') {
$condition[0] .= " AND `gravity` = ? "; $condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_COMMENT]);
$condition[] = Item::GRAVITY_COMMENT; } elseif ($filter === 'posts') {
} $condition = DBA::mergeConditions($condition, ['gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_ACTIVITY]]);
if ($owner['account-type'] != User::ACCOUNT_TYPE_COMMUNITY) {
$condition[0] .= " AND `contact-id` = ? AND `author-id` = ?";
$condition[] = $owner['id'];
$condition[] = $authorid;
} }
$params = ['order' => ['received' => true], 'limit' => $max_items]; $params = ['order' => ['received' => true], 'limit' => $max_items];
if ($filter === 'posts') { $ret = Post::selectOrigin(Item::DELIVER_FIELDLIST, $condition, $params);
$ret = Post::selectOriginThread(Item::DELIVER_FIELDLIST, $condition, $params);
} else {
$ret = Post::selectOrigin(Item::DELIVER_FIELDLIST, $condition, $params);
}
$items = Post::toArray($ret); $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; $doc->formatOutput = true;
$root = self::addHeader($doc, $owner, $filter); $root = self::addHeader($doc, $owner, $filter);