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:
commit
58dff940ff
2 changed files with 32 additions and 2 deletions
|
@ -134,7 +134,8 @@ class User
|
||||||
`user`.`spubkey`,
|
`user`.`spubkey`,
|
||||||
`user`.`page-flags`,
|
`user`.`page-flags`,
|
||||||
`user`.`account-type`,
|
`user`.`account-type`,
|
||||||
`user`.`prvnets`
|
`user`.`prvnets`,
|
||||||
|
`user`.`account_removed`
|
||||||
FROM `contact`
|
FROM `contact`
|
||||||
INNER JOIN `user`
|
INNER JOIN `user`
|
||||||
ON `user`.`uid` = `contact`.`uid`
|
ON `user`.`uid` = `contact`.`uid`
|
||||||
|
|
|
@ -153,7 +153,9 @@ class Notifier
|
||||||
if (!empty($target_item) && !empty($items)) {
|
if (!empty($target_item) && !empty($items)) {
|
||||||
$parent = $items[0];
|
$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']);
|
$delivery_queue_count += self::activityPubDelivery($cmd, $target_item, $parent, $a->queue['priority'], $a->queue['created']);
|
||||||
|
}
|
||||||
|
|
||||||
$fields = ['network', 'author-id', 'owner-id'];
|
$fields = ['network', 'author-id', 'owner-id'];
|
||||||
$condition = ['uri' => $target_item["thr-parent"], 'uid' => $target_item["uid"]];
|
$condition = ['uri' => $target_item["thr-parent"], 'uid' => $target_item["uid"]];
|
||||||
|
@ -425,6 +427,11 @@ class Notifier
|
||||||
|
|
||||||
if (DBA::isResult($r)) {
|
if (DBA::isResult($r)) {
|
||||||
foreach ($r as $rr) {
|
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))) {
|
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);
|
Logger::log('Skipping contact ' . $rr['url'] . ' since it will be delivered via AP', Logger::DEBUG);
|
||||||
continue;
|
continue;
|
||||||
|
@ -453,6 +460,11 @@ class Notifier
|
||||||
|
|
||||||
// delivery loop
|
// delivery loop
|
||||||
while ($contact = DBA::fetch($delivery_contacts_stmt)) {
|
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))) {
|
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);
|
Logger::log('Skipping contact ' . $contact['url'] . ' since it will be delivered via AP', Logger::DEBUG);
|
||||||
continue;
|
continue;
|
||||||
|
@ -524,6 +536,23 @@ class Notifier
|
||||||
return;
|
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 $self_user_id
|
||||||
* @param int $priority The priority the Notifier queue item was created with
|
* @param int $priority The priority the Notifier queue item was created with
|
||||||
|
|
Loading…
Reference in a new issue