From 5ed1c12349d2dacb4f247afda3587ef2550e2a5f Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 5 Oct 2018 19:48:48 +0000 Subject: [PATCH 1/2] Send a follow request upon contact switch to AP --- src/Protocol/ActivityPub/Receiver.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 30d710702..14b5e93ba 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -357,11 +357,11 @@ class Receiver } /** - * @brief + * @brief Switches existing contacts to ActivityPub * - * @param $cid + * @param integer $cid Contact ID * @param integer $uid User ID - * @param $url + * @param string $url Profile URL */ private static function switchContact($cid, $uid, $url) { @@ -370,7 +370,7 @@ class Receiver return; } - logger('Switch contact ' . $cid . ' (' . $profile['url'] . ') for user ' . $uid . ' from OStatus to ActivityPub'); + logger('Switch contact ' . $cid . ' (' . $profile['url'] . ') for user ' . $uid . ' to ActivityPub'); $photo = $profile['photo']; unset($profile['photo']); @@ -381,7 +381,11 @@ class Receiver Contact::updateAvatar($photo, $uid, $cid); - /// @todo Send a new follow request to be sure that the connection still exists + // Send a new follow request to be sure that the connection still exists + if (DBA::exists('contact', ['id' => $cid, 'rel' => [Contact::SHARING, Contact::FRIEND]])) { + ActivityPub\Transmitter::sendActivity('Follow', $profile['url'], $uid); + logger('Send a new follow request to ' . $profile['url'] . ' for user ' . $uid, LOGGER_DEBUG); + } } /** From 5d7968bdf3e65738bfec5ec8df89c32e58540a51 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 5 Oct 2018 20:10:10 +0000 Subject: [PATCH 2/2] Avoid to do the follow stuff for the public user --- src/Protocol/ActivityPub/Receiver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 14b5e93ba..5c644176f 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -382,7 +382,7 @@ class Receiver Contact::updateAvatar($photo, $uid, $cid); // Send a new follow request to be sure that the connection still exists - if (DBA::exists('contact', ['id' => $cid, 'rel' => [Contact::SHARING, Contact::FRIEND]])) { + if (($uid != 0) && DBA::exists('contact', ['id' => $cid, 'rel' => [Contact::SHARING, Contact::FRIEND]])) { ActivityPub\Transmitter::sendActivity('Follow', $profile['url'], $uid); logger('Send a new follow request to ' . $profile['url'] . ' for user ' . $uid, LOGGER_DEBUG); }