Merge pull request #8594 from annando/issue-8586

Issue 8586 again: Don't transmit participations
This commit is contained in:
Hypolite Petovan 2020-05-06 17:32:31 -04:00 committed by GitHub
commit 71c45330be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 3 deletions

View file

@ -1989,7 +1989,19 @@ 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'] || ($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;
}
}
if ($transmit) {
Worker::add(['priority' => $priority, 'dont_fork' => true], 'Notifier', $notify_type, $current_post);
}

View file

@ -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'], ['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']) {
if (in_array($comment["verb"], [Activity::FOLLOW, Activity::TAG])) {
Logger::info('participation messages are not relayed', ['item' => $comment['id']]);
continue;
}