Merge pull request #7277 from annando/ignore-resharer

Issue #5983: Ignore reshares from blocked and ignored contacts
This commit is contained in:
Hypolite Petovan 2019-06-17 09:01:31 -04:00 committed by GitHub
commit 2c19b8c8e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 7 deletions

View file

@ -1453,7 +1453,7 @@ class Item extends BaseObject
return 0;
}
if (!empty($uid) && Contact::isBlockedByUser($item['author-link'], $uid)) {
if (!empty($uid) && Contact::isBlockedByUser($item['author-id'], $uid)) {
Logger::notice('Author is blocked by user', ['author-link' => $item['author-link'], 'uid' => $uid, 'item-uri' => $item['uri']]);
return 0;
}
@ -1473,11 +1473,26 @@ class Item extends BaseObject
return 0;
}
if (!empty($uid) && Contact::isBlockedByUser($item['owner-link'], $uid)) {
if (!empty($uid) && Contact::isBlockedByUser($item['owner-id'], $uid)) {
Logger::notice('Owner is blocked by user', ['owner-link' => $item['owner-link'], 'uid' => $uid, 'item-uri' => $item['uri']]);
return 0;
}
// The causer is set during a thread completion, for example because of a reshare. It countains the responsible actor.
if (!empty($uid) && !empty($item['causer-id']) && Contact::isBlockedByUser($item['causer-id'], $uid)) {
Logger::notice('Causer is blocked by user', ['causer-link' => $item['causer-link'], 'uid' => $uid, 'item-uri' => $item['uri']]);
return 0;
}
if (!empty($uid) && !empty($item['causer-id']) && ($item['parent-uri'] == $item['uri']) && Contact::isIgnoredByUser($item['causer-id'], $uid)) {
Logger::notice('Causer is ignored by user', ['causer-link' => $item['causer-link'], 'uid' => $uid, 'item-uri' => $item['uri']]);
return 0;
}
// We don't store the causer, we only have it here for the checks above
unset($item['causer-id']);
unset($item['causer-link']);
if ($item['network'] == Protocol::PHANTOM) {
$item['network'] = Protocol::DFRN;
Logger::notice('Missing network, setting to {network}.', [

View file

@ -370,12 +370,15 @@ class Processor
$item['private'] = !in_array(0, $activity['receiver']);
$item['author-link'] = $activity['author'];
$item['author-id'] = Contact::getIdForURL($activity['author'], 0, true);
$item['owner-link'] = $activity['actor'];
$item['owner-id'] = Contact::getIdForURL($activity['actor'], 0, true);
if (empty($activity['thread-completion'])) {
$item['owner-link'] = $activity['actor'];
$item['owner-id'] = Contact::getIdForURL($activity['actor'], 0, true);
} else {
Logger::info('Ignoring actor because of thread completion.');
if (!empty($activity['thread-completion'])) {
// Store the original actor in the "causer" fields to enable the check for ignored or blocked contacts
$item['causer-link'] = $item['owner-link'];
$item['causer-id'] = $item['owner-id'];
Logger::info('Ignoring actor because of thread completion.', ['actor' => $item['owner-link']]);
$item['owner-link'] = $item['author-link'];
$item['owner-id'] = $item['author-id'];
}