From de1c0f4c139fcbb5341a3176e12bf5dad53c802b Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 20 Dec 2022 19:25:57 +0000 Subject: [PATCH] Don't display Diaspora reshares --- src/Content/Conversation.php | 16 ++++++++-------- src/Model/Contact.php | 4 ++-- src/Module/Api/Mastodon/Accounts/Statuses.php | 9 +++++---- .../Notifications/Factory/Notification.php | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/Content/Conversation.php b/src/Content/Conversation.php index aa7c016180..d9036c7839 100644 --- a/src/Content/Conversation.php +++ b/src/Content/Conversation.php @@ -985,8 +985,8 @@ class Conversation $thread_items = Post::selectForUser($uid, array_merge(ItemModel::DISPLAY_FIELDLIST, ['featured', 'contact-uid', 'gravity', 'post-type', 'post-reason']), $condition, $params); - $items = []; - $quoteuriids = []; + $items = []; + $quote_uri_ids = []; while ($row = Post::fetch($thread_items)) { if (!empty($items[$row['uri-id']]) && ($row['uid'] == 0)) { @@ -1007,7 +1007,7 @@ class Conversation } if (in_array($row['gravity'], [ItemModel::GRAVITY_PARENT, ItemModel::GRAVITY_COMMENT])) { - $quoteuriids[$row['uri-id']] = [ + $quote_uri_ids[$row['uri-id']] = [ 'uri-id' => $row['uri-id'], 'uri' => $row['uri'], 'parent-uri-id' => $row['parent-uri-id'], @@ -1020,7 +1020,7 @@ class Conversation DBA::close($thread_items); - $quotes = Post::select(array_merge(ItemModel::DISPLAY_FIELDLIST, ['featured', 'contact-uid', 'gravity', 'post-type', 'post-reason']), ['quote-uri-id' => array_column($quoteuriids, 'uri-id'), 'body' => '', 'uid' => 0]); + $quotes = Post::select(array_merge(ItemModel::DISPLAY_FIELDLIST, ['featured', 'contact-uid', 'gravity', 'post-type', 'post-reason']), ['quote-uri-id' => array_column($quote_uri_ids, 'uri-id'), 'body' => '', 'uid' => 0]); while ($quote = Post::fetch($quotes)) { $row = $quote; @@ -1028,10 +1028,10 @@ class Conversation $row['verb'] = $row['body'] = $row['raw-body'] = Activity::ANNOUNCE; $row['gravity'] = ItemModel::GRAVITY_ACTIVITY; $row['object-type'] = Activity\ObjectType::NOTE; - $row['parent-uri'] = $quoteuriids[$quote['quote-uri-id']]['parent-uri']; - $row['parent-uri-id'] = $quoteuriids[$quote['quote-uri-id']]['parent-uri-id']; - $row['thr-parent'] = $quoteuriids[$quote['quote-uri-id']]['uri']; - $row['thr-parent-id'] = $quoteuriids[$quote['quote-uri-id']]['uri-id']; + $row['parent-uri'] = $quote_uri_ids[$quote['quote-uri-id']]['parent-uri']; + $row['parent-uri-id'] = $quote_uri_ids[$quote['quote-uri-id']]['parent-uri-id']; + $row['thr-parent'] = $quote_uri_ids[$quote['quote-uri-id']]['uri']; + $row['thr-parent-id'] = $quote_uri_ids[$quote['quote-uri-id']]['uri-id']; $items[$row['uri-id']] = $this->addRowInformation($row, [], []); } diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 392f777615..2003b4608e 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1544,8 +1544,8 @@ class Contact $contact_field = ((($contact["contact-type"] == self::TYPE_COMMUNITY) || ($contact['network'] == Protocol::MAIL)) ? 'owner-id' : 'author-id'); if ($thread_mode) { - $condition = ["((`$contact_field` = ? AND `gravity` = ?) OR (`author-id` = ? AND `gravity` = ? AND `vid` = ? AND `thr-parent-id` = `parent-uri-id`)) AND " . $sql, - $cid, Item::GRAVITY_PARENT, $cid, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), DI::userSession()->getLocalUserId()]; + $condition = ["((`$contact_field` = ? AND `gravity` = ?) OR (`author-id` = ? AND `gravity` = ? AND `vid` = ? AND `protocol` != ? AND `thr-parent-id` = `parent-uri-id`)) AND " . $sql, + $cid, Item::GRAVITY_PARENT, $cid, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Conversation::PARCEL_DIASPORA, DI::userSession()->getLocalUserId()]; } else { $condition = ["`$contact_field` = ? AND `gravity` IN (?, ?) AND " . $sql, $cid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, DI::userSession()->getLocalUserId()]; diff --git a/src/Module/Api/Mastodon/Accounts/Statuses.php b/src/Module/Api/Mastodon/Accounts/Statuses.php index b9bb63ae78..36f730404a 100644 --- a/src/Module/Api/Mastodon/Accounts/Statuses.php +++ b/src/Module/Api/Mastodon/Accounts/Statuses.php @@ -26,6 +26,7 @@ use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; +use Friendica\Model\Conversation; use Friendica\Model\Item; use Friendica\Model\Post; use Friendica\Model\Verb; @@ -81,11 +82,11 @@ class Statuses extends BaseApi if (!$request['pinned'] && !$request['only_media']) { if ($request['exclude_replies']) { - $condition = DBA::mergeConditions($condition, ["(`gravity` = ? OR (`gravity` = ? AND `vid` = ?))", - Item::GRAVITY_PARENT, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE)]); + $condition = DBA::mergeConditions($condition, ["(`gravity` = ? OR (`gravity` = ? AND `vid` = ? AND `protocol` != ?))", + Item::GRAVITY_PARENT, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Conversation::PARCEL_DIASPORA]); } else { - $condition = DBA::mergeConditions($condition, ["(`gravity` IN (?, ?) OR (`gravity` = ? AND `vid` = ?))", - Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE)]); + $condition = DBA::mergeConditions($condition, ["(`gravity` IN (?, ?) OR (`gravity` = ? AND `vid` = ? AND `protocol` != ?))", + Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Conversation::PARCEL_DIASPORA]); } } elseif ($request['exclude_replies']) { $condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]); diff --git a/src/Navigation/Notifications/Factory/Notification.php b/src/Navigation/Notifications/Factory/Notification.php index 86d462e0b2..6368820f6a 100644 --- a/src/Navigation/Notifications/Factory/Notification.php +++ b/src/Navigation/Notifications/Factory/Notification.php @@ -315,7 +315,7 @@ class Notification extends BaseFactory implements ICanCreateFromTableRow case Post\UserNotification::TYPE_QUOTED: $msg = $l10n->t('%1$s shared your post %2$s'); break; - } + } break; } } -- 2.39.5