From: Michael Vogel Date: Thu, 11 Jul 2019 20:11:51 +0000 (+0200) Subject: Use standard function to update the contact to avoid SQL errors X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=807d2665ea112a2ca72375fff7943fe77d704b44;p=friendica.git Use standard function to update the contact to avoid SQL errors --- diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index a8b5a18db1..f830f857a7 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -657,27 +657,14 @@ class Receiver */ public static function switchContact($cid, $uid, $url) { - $profile = ActivityPub::probeProfile($url); - if (empty($profile)) { - return; - } - - Logger::log('Switch contact ' . $cid . ' (' . $profile['url'] . ') for user ' . $uid . ' to ActivityPub'); - - $photo = defaults($profile, 'photo', null); - unset($profile['photo']); - unset($profile['baseurl']); - unset($profile['guid']); - - $profile['nurl'] = Strings::normaliseLink($profile['url']); - DBA::update('contact', $profile, ['id' => $cid]); + Contact::updateFromProbe($cid, '', true); - Contact::updateAvatar($photo, $uid, $cid); + Logger::log('Switch contact ' . $cid . ' (' . $url . ') for user ' . $uid . ' to ActivityPub'); // 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]])) { - ActivityPub\Transmitter::sendActivity('Follow', $profile['url'], $uid); - Logger::log('Send a new follow request to ' . $profile['url'] . ' for user ' . $uid, Logger::DEBUG); + ActivityPub\Transmitter::sendActivity('Follow', $url, $uid); + Logger::log('Send a new follow request to ' . $url . ' for user ' . $uid, Logger::DEBUG); } }