From ea9d0fb9b037ab09f0cb0a420e6777591be1a093 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 2 Nov 2024 17:35:49 +0000 Subject: [PATCH] Process deletions via ActivityPub --- src/Model/Contact.php | 2 +- src/Protocol/ActivityPub/Transmitter.php | 2 +- src/Protocol/DFRN.php | 3 ++- src/Protocol/Diaspora.php | 2 +- src/Util/HTTPSignature.php | 4 +++- src/Worker/Notifier.php | 2 +- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index a440d1e599..a9ef2276ab 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1082,7 +1082,7 @@ class Contact */ public static function markForArchival(array $contact) { - if ((!isset($contact['url']) || !isset($contact['uri-id'])) && !empty($contact['id'])) { + if ((!isset($contact['uri-id']) || !isset($contact['url']) || !isset($contact['archive']) || !isset($contact['self']) || !isset($contact['term-date'])) && !empty($contact['id'])) { $fields = ['id', 'uri-id', 'url', 'archive', 'self', 'term-date']; $contact = DBA::selectFirst('contact', $fields, ['id' => $contact['id']]); if (!DBA::isResult($contact)) { diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index ad53f22a21..883a97c10a 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -1391,7 +1391,7 @@ class Transmitter } } - if (!$api_mode && !$item['origin']) { + if (!$api_mode && !$item['deleted'] && !$item['origin']) { Logger::debug('Post is not ours and is not stored', ['id' => $item['id'], 'uri-id' => $item['uri-id']]); return false; } diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 7b82adaf91..8ea8dfd37a 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -986,7 +986,7 @@ class DFRN Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); return -25; } - Item::incrementOutbound(Protocol::DFRN); + $xml = $postResult->getBodyString(); $curl_stat = $postResult->getReturnCode(); @@ -1017,6 +1017,7 @@ class DFRN if (!empty($contact['gsid'])) { GServer::setReachableById($contact['gsid'], Protocol::DFRN); + Item::incrementOutbound(Protocol::DFRN); } if (!empty($res->message)) { diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 94fec1b00d..74963025e9 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -2962,7 +2962,6 @@ class Diaspora return 0; } $return_code = $postResult->getReturnCode(); - Item::incrementOutbound(Protocol::DIASPORA); } else { Logger::notice('test_mode'); return 200; @@ -2971,6 +2970,7 @@ class Diaspora if (!empty($contact['gsid']) && (empty($return_code) || $postResult->isTimeout())) { GServer::setFailureById($contact['gsid']); } elseif (!empty($contact['gsid']) && ($return_code >= 200) && ($return_code <= 299)) { + Item::incrementOutbound(Protocol::DIASPORA); GServer::setReachableById($contact['gsid'], Protocol::DIASPORA); } diff --git a/src/Util/HTTPSignature.php b/src/Util/HTTPSignature.php index 68bd049855..0fdfccf330 100644 --- a/src/Util/HTTPSignature.php +++ b/src/Util/HTTPSignature.php @@ -297,7 +297,9 @@ class HTTPSignature self::setInboxStatus($target, ($return_code >= 200) && ($return_code <= 299)); - Item::incrementOutbound(Protocol::ACTIVITYPUB); + if (($return_code >= 200) && ($return_code <= 299)) { + Item::incrementOutbound(Protocol::ACTIVITYPUB); + } return $postResult; } diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index 760d324d2d..f693d3da53 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -527,7 +527,7 @@ class Notifier continue; } - Logger::info('Delivery', ['batch' => $in_batch, 'target' => $post_uriid, 'uid' => $sender_uid, 'guid' => $target_item['guid'] ?? '', 'to' => $contact]); + Logger::info('Delivery', ['cmd' => $cmd, 'batch' => $in_batch, 'target' => $post_uriid, 'uid' => $sender_uid, 'guid' => $target_item['guid'] ?? '', 'to' => $contact]); // Ensure that posts with our own protocol arrives before Diaspora posts arrive. // Situation is that sometimes Friendica servers receive Friendica posts over the Diaspora protocol first.