Merge pull request #6422 from annando/private-answer

Don't accept private answers to public parents
This commit is contained in:
Hypolite Petovan 2019-01-11 01:07:04 -05:00 committed by GitHub
commit 3020b9cb06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -264,6 +264,19 @@ class Processor
} }
$item['uri'] = $activity['id']; $item['uri'] = $activity['id'];
if (($item['parent-uri'] != $item['uri']) && ($item['gravity'] == GRAVITY_COMMENT)) {
$item_private = !in_array(0, $activity['item_receiver']);
$parent = Item::selectFirst(['private'], ['uri' => $item['parent-uri']]);
if (!DBA::isResult($parent)) {
return;
}
if ($item_private && !$parent['private']) {
Logger::log('Item ' . $item['uri'] . ' is private but the parent ' . $item['parent-uri'] . ' is not. So we drop it.');
return;
}
}
$item['created'] = $activity['published']; $item['created'] = $activity['published'];
$item['edited'] = $activity['updated']; $item['edited'] = $activity['updated'];
$item['guid'] = $activity['diaspora:guid']; $item['guid'] = $activity['diaspora:guid'];

View file

@ -233,6 +233,7 @@ class Receiver
$object_data['type'] = $type; $object_data['type'] = $type;
$object_data['actor'] = $actor; $object_data['actor'] = $actor;
$object_data['item_receiver'] = $receivers;
$object_data['receiver'] = array_merge(defaults($object_data, 'receiver', []), $receivers); $object_data['receiver'] = array_merge(defaults($object_data, 'receiver', []), $receivers);
Logger::log('Processing ' . $object_data['type'] . ' ' . $object_data['object_type'] . ' ' . $object_data['id'], Logger::DEBUG); Logger::log('Processing ' . $object_data['type'] . ' ' . $object_data['object_type'] . ' ' . $object_data['id'], Logger::DEBUG);