From 7dea1ff6bdc5ea5949a0232adf37db6dfd236b97 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 6 May 2020 17:30:21 +0000 Subject: [PATCH 1/4] Issue 8586 again: Don't transmit participations --- src/Protocol/Diaspora.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 044740d3c..708b6597e 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -2327,9 +2327,9 @@ class Diaspora Logger::info('Participation stored', ['id' => $message_id, 'guid' => $guid, 'parent_guid' => $parent_guid, 'author' => $author]); // Send all existing comments and likes to the requesting server - $comments = Item::select(['id', 'uri-id', 'parent'], ['parent' => $parent_item['id']]); + $comments = Item::select(['id', 'uri-id', 'parent', 'verb'], ['parent' => $parent_item['id']]); while ($comment = Item::fetch($comments)) { - if ($comment['id'] == $comment['parent']) { + if ($comment['id'] == $comment['parent'] || in_array($comment["verb"], [Activity::FOLLOW, Activity::TAG])) { continue; } From 806f4a01426963f5adfb9b0c7bd04fafa4a1727e Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 6 May 2020 19:00:56 +0000 Subject: [PATCH 2/4] Added logging --- src/Protocol/Diaspora.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 708b6597e..e5afd5602 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -261,6 +261,7 @@ class Diaspora public static function participantsForThread(array $item, array $contacts) { if (!in_array($item['private'], [Item::PUBLIC, Item::UNLISTED]) || in_array($item["verb"], [Activity::FOLLOW, Activity::TAG])) { + Logger::info('Item is private or a participation request. It will not be relayed', ['guid' => $item['guid'], 'private' => $item['private'], 'verb' => $item['verb']]); return $contacts; } @@ -2283,6 +2284,10 @@ class Diaspora return false; } + if (!$parent_item['origin']) { + Logger::info('Not our origin. Participation is ignored', ['parent_guid' => $parent_guid, 'guid' => $guid, 'author' => $author]); + } + if (!in_array($parent_item['private'], [Item::PUBLIC, Item::UNLISTED])) { Logger::info('Item is not public, participation is ignored', ['parent_guid' => $parent_guid, 'guid' => $guid, 'author' => $author]); return false; @@ -2327,9 +2332,10 @@ class Diaspora Logger::info('Participation stored', ['id' => $message_id, 'guid' => $guid, 'parent_guid' => $parent_guid, 'author' => $author]); // Send all existing comments and likes to the requesting server - $comments = Item::select(['id', 'uri-id', 'parent', 'verb'], ['parent' => $parent_item['id']]); + $comments = Item::select(['id', 'uri-id', 'parent', 'verb'], ['parent' => $parent_item['id'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]]); while ($comment = Item::fetch($comments)) { - if ($comment['id'] == $comment['parent'] || in_array($comment["verb"], [Activity::FOLLOW, Activity::TAG])) { + if (in_array($comment["verb"], [Activity::FOLLOW, Activity::TAG])) { + Logger::info('participation messages are not relayed', ['item' => $comment['id']]); continue; } From be9519708eb3ffa523ef82b2271be610ea999e7e Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 6 May 2020 20:43:00 +0000 Subject: [PATCH 3/4] Don't relay participation messages --- src/Model/Item.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index 17c841fc2..ff3ec9a72 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1989,7 +1989,18 @@ class Item check_user_notification($current_post); - if ($notify || ($item['visible'] && ((!empty($parent) && $parent['origin']) || $item['origin']))) { + $transmit = $notify || ($item['visible'] && ((!empty($parent) && $parent['origin']) || $item['origin'])); + + if ($transmit) { + $transmit_item = Item::selectFirst(['verb', 'origin'], ['id' => $item['id']]); + // Don't relay participation messages + if (($transmit_item['verb'] == Activity::FOLLOW) && !$transmit_item['origin']) { + Logger::info('Participation messages will not be relayed', ['item' => $item['id'], 'uri' => $item['uri'], 'verb' => $transmit_item['verb']]); + $transmit = false; + } + } + + if ($transmit) { Worker::add(['priority' => $priority, 'dont_fork' => true], 'Notifier', $notify_type, $current_post); } From 065fad31f155700f5d1280ed5f94b6871c3a262e Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 6 May 2020 21:19:48 +0000 Subject: [PATCH 4/4] ignore "follow" activities that are not from the user --- src/Model/Item.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index ff3ec9a72..44e00b09b 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1994,7 +1994,8 @@ class Item if ($transmit) { $transmit_item = Item::selectFirst(['verb', 'origin'], ['id' => $item['id']]); // Don't relay participation messages - if (($transmit_item['verb'] == Activity::FOLLOW) && !$transmit_item['origin']) { + if (($transmit_item['verb'] == Activity::FOLLOW) && + (!$transmit_item['origin'] || ($item['author-id'] != Contact::getPublicIdByUserId($uid)))) { Logger::info('Participation messages will not be relayed', ['item' => $item['id'], 'uri' => $item['uri'], 'verb' => $transmit_item['verb']]); $transmit = false; }