From 3c1380fdcc16817fc51b269433d1d6b6438c28f5 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 11 Sep 2019 16:54:13 +0000 Subject: [PATCH] Fix enduring follow requests to Pleroma --- src/Protocol/ActivityPub/Receiver.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index bb676b396e..058d210a24 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -656,14 +656,19 @@ class Receiver */ public static function switchContact($cid, $uid, $url) { - Contact::updateFromProbe($cid, '', true); + if (DBA::exists('contact', ['id' => $cid, 'network' => Protocol::ACTIVITYPUB])) { + Logger::info('Contact is already ActivityPub', ['id' => $cid, 'uid' => $uid, 'url' => $url]); + return; + } - Logger::log('Switch contact ' . $cid . ' (' . $url . ') for user ' . $uid . ' to ActivityPub'); + if (Contact::updateFromProbe($cid, '', true)) { + Logger::info('Update was successful', ['id' => $cid, 'uid' => $uid, 'url' => $url]); + } // Send a new follow request to be sure that the connection still exists - if (($uid != 0) && DBA::exists('contact', ['id' => $cid, 'rel' => [Contact::SHARING, Contact::FRIEND]])) { + if (($uid != 0) && DBA::exists('contact', ['id' => $cid, 'rel' => [Contact::SHARING, Contact::FRIEND], 'network' => Protocol::ACTIVITYPUB])) { + Logger::info('Contact had been switched to ActivityPub. Sending a new follow request.', ['uid' => $uid, 'url' => $url]); ActivityPub\Transmitter::sendActivity('Follow', $url, $uid); - Logger::log('Send a new follow request to ' . $url . ' for user ' . $uid, Logger::DEBUG); } } -- 2.39.5