diff --git a/src/Model/User.php b/src/Model/User.php index 59ca4c90a4..472ed09247 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -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` diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index 681fd13c8f..4492e3ce92 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -153,7 +153,9 @@ class Notifier if (!empty($target_item) && !empty($items)) { $parent = $items[0]; - $delivery_queue_count += self::activityPubDelivery($cmd, $target_item, $parent, $a->queue['priority'], $a->queue['created']); + 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