diff --git a/include/conversation.php b/include/conversation.php index a4fe9c00e3..5b7ccbd8a1 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -769,20 +769,12 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid) $items = []; + $follow = Item::activityToIndex(Activity::FOLLOW); + foreach ($parents AS $parent) { - $condition = ["`item`.`parent-uri` = ? AND `item`.`uid` IN (0, ?) ", - $parent['uri'], $uid]; - if ($block_authors) { - $condition[0] .= "AND NOT `author`.`hidden`"; - } - - $thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity']), $condition, $params); - - $comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false); - - if (count($comments) != 0) { - $items = array_merge($items, $comments); - } + $condition = ["`item`.`parent-uri` = ? AND `item`.`uid` IN (0, ?) AND (`activity` != ? OR `activity` IS NULL)", + $parent['uri'], $uid, $follow]; + $items = conversation_fetch_items($parent, $items, $condition, $block_authors, $params); } foreach ($items as $index => $item) { @@ -796,6 +788,31 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid) return $items; } +/** + * Fetch conversation items + * + * @param array $parent + * @param array $items + * @param array $condition + * @param boolean $block_authors + * @param array $params + * @return array + */ +function conversation_fetch_items(array $parent, array $items, array $condition, bool $block_authors, array $params) { + if ($block_authors) { + $condition[0] .= "AND NOT `author`.`hidden`"; + } + + $thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity']), $condition, $params); + + $comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false); + + if (count($comments) != 0) { + $items = array_merge($items, $comments); + } + return $items; +} + function item_photo_menu($item) { $sub_link = ''; $poke_link = ''; diff --git a/mod/ping.php b/mod/ping.php index 3057fb9e31..3dab119700 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -30,6 +30,7 @@ use Friendica\Model\Contact; use Friendica\Model\Group; use Friendica\Model\Item; use Friendica\Model\Notify\Type; +use Friendica\Protocol\Activity; use Friendica\Util\DateTimeFormat; use Friendica\Util\Temporal; use Friendica\Util\Proxy as ProxyUtils; @@ -134,9 +135,10 @@ function ping_init(App $a) $notifs = ping_get_notifications(local_user()); - $condition = ["`unseen` AND `uid` = ? AND `contact-id` != ?", local_user(), local_user()]; + $condition = ["`unseen` AND `uid` = ? AND `contact-id` != ? AND (`activity` != ? OR `activity` IS NULL)", + local_user(), local_user(), Item::activityToIndex(Activity::FOLLOW)]; $fields = ['id', 'parent', 'verb', 'author-name', 'unseen', 'author-link', 'author-avatar', 'contact-avatar', - 'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid', 'wall']; + 'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid', 'wall', 'activity']; $params = ['order' => ['received' => true]]; $items = Item::selectForUser(local_user(), $fields, $condition, $params); diff --git a/src/Model/Item.php b/src/Model/Item.php index 44e00b09b3..38ea35c8f6 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -74,7 +74,7 @@ class Item 'event-id', 'event-created', 'event-edited', 'event-start', 'event-finish', 'event-summary', 'event-desc', 'event-location', 'event-type', 'event-nofinish', 'event-adjust', 'event-ignore', 'event-id', - 'delivery_queue_count', 'delivery_queue_done', 'delivery_queue_failed' + 'delivery_queue_count', 'delivery_queue_done', 'delivery_queue_failed', 'activity' ]; // Field list that is used to deliver items via the protocols @@ -1672,7 +1672,13 @@ class Item $allow_gid = $parent['allow_gid']; $deny_cid = $parent['deny_cid']; $deny_gid = $parent['deny_gid']; - $item['wall'] = $parent['wall']; + + // Don't federate received participation messages + if ($item['verb'] != Activity::FOLLOW) { + $item['wall'] = $parent['wall']; + } else { + $item['wall'] = false; + } /* * If the parent is private, force privacy for the entire conversation