Merge pull request #8817 from annando/ap-diaspora-delivery

Prevent delivering AP comments to Diaspora
This commit is contained in:
Hypolite Petovan 2020-06-27 09:30:11 -04:00 committed by GitHub
commit e78db3fac6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 9 deletions

View file

@ -2332,13 +2332,24 @@ 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'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]]);
$comments = Item::select(['id', 'uri-id', 'parent-author-network', 'author-network', 'verb'],
['parent' => $parent_item['id'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]]);
while ($comment = Item::fetch($comments)) {
if (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;
}
if ($comment['author-network'] == Protocol::ACTIVITYPUB) {
Logger::info('Comments from ActivityPub authors are not relayed', ['item' => $comment['id']]);
continue;
}
if ($comment['parent-author-network'] == Protocol::ACTIVITYPUB) {
Logger::info('Comments to comments from ActivityPub authors are not relayed', ['item' => $comment['id']]);
continue;
}
Logger::info('Deliver participation', ['item' => $comment['id'], 'contact' => $author_contact["cid"]]);
if (Worker::add(PRIORITY_HIGH, 'Delivery', Delivery::POST, $comment['id'], $author_contact["cid"])) {
Post\DeliveryData::incrementQueueCount($comment['uri-id'], 1);