Merge pull request #6639 from annando/delete-removal

Don't send single item deletions to protocols that support account removal
This commit is contained in:
Hypolite Petovan 2019-02-11 18:15:42 -05:00 committed by GitHub
commit 58dff940ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 2 deletions

View file

@ -134,7 +134,8 @@ class User
`user`.`spubkey`,
`user`.`page-flags`,
`user`.`account-type`,
`user`.`prvnets`
`user`.`prvnets`,
`user`.`account_removed`
FROM `contact`
INNER JOIN `user`
ON `user`.`uid` = `contact`.`uid`

View file

@ -153,7 +153,9 @@ class Notifier
if (!empty($target_item) && !empty($items)) {
$parent = $items[0];
if (!self::isRemovalActivity($cmd, $owner, Protocol::ACTIVITYPUB)) {
$delivery_queue_count += self::activityPubDelivery($cmd, $target_item, $parent, $a->queue['priority'], $a->queue['created']);
}
$fields = ['network', 'author-id', 'owner-id'];
$condition = ['uri' => $target_item["thr-parent"], 'uid' => $target_item["uid"]];
@ -425,6 +427,11 @@ class Notifier
if (DBA::isResult($r)) {
foreach ($r as $rr) {
if (self::isRemovalActivity($cmd, $owner, $rr['network'])) {
Logger::log('Skipping dropping for ' . $rr['url'] . ' since the network supports account removal commands.', Logger::DEBUG);
continue;
}
if (Config::get('debug', 'total_ap_delivery') && !empty($rr['url']) && ($rr['network'] == Protocol::DFRN) && !empty(APContact::getByURL($rr['url'], false))) {
Logger::log('Skipping contact ' . $rr['url'] . ' since it will be delivered via AP', Logger::DEBUG);
continue;
@ -453,6 +460,11 @@ class Notifier
// delivery loop
while ($contact = DBA::fetch($delivery_contacts_stmt)) {
if (self::isRemovalActivity($cmd, $owner, $contact['network'])) {
Logger::log('Skipping dropping for ' . $contact['url'] . ' since the network supports account removal commands.', Logger::DEBUG);
continue;
}
if (Config::get('debug', 'total_ap_delivery') && ($contact['network'] == Protocol::DFRN) && !empty(APContact::getByURL($contact['url'], false))) {
Logger::log('Skipping contact ' . $contact['url'] . ' since it will be delivered via AP', Logger::DEBUG);
continue;
@ -524,6 +536,23 @@ class Notifier
return;
}
/**
* Checks if the current action is a deletion command of a account removal activity
* For Diaspora and ActivityPub we don't need to send single item deletion calls.
* These protocols do have a dedicated command for deleting a whole account.
*
* @param string $cmd Notifier command
* @param array $owner Sender of the post
* @param string $network Receiver network
* @return bool
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
private static function isRemovalActivity($cmd, $owner, $network)
{
return ($cmd == Delivery::DELETION) && $owner['account_removed'] && in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DIASPORA]);
}
/**
* @param int $self_user_id
* @param int $priority The priority the Notifier queue item was created with