Browse Source

Use standard function to update the contact to avoid SQL errors

pull/7368/head
Michael Vogel 1 week ago
parent
commit
807d2665ea
1 changed files with 4 additions and 17 deletions
  1. 4
    17
      src/Protocol/ActivityPub/Receiver.php

+ 4
- 17
src/Protocol/ActivityPub/Receiver.php View File

@@ -657,27 +657,14 @@ class Receiver
657 657
 	 */
658 658
 	public static function switchContact($cid, $uid, $url)
659 659
 	{
660
-		$profile = ActivityPub::probeProfile($url);
661
-		if (empty($profile)) {
662
-			return;
663
-		}
664
-
665
-		Logger::log('Switch contact ' . $cid . ' (' . $profile['url'] . ') for user ' . $uid . ' to ActivityPub');
666
-
667
-		$photo = defaults($profile, 'photo', null);
668
-		unset($profile['photo']);
669
-		unset($profile['baseurl']);
670
-		unset($profile['guid']);
671
-
672
-		$profile['nurl'] = Strings::normaliseLink($profile['url']);
673
-		DBA::update('contact', $profile, ['id' => $cid]);
660
+		Contact::updateFromProbe($cid, '', true);
674 661
 
675
-		Contact::updateAvatar($photo, $uid, $cid);
662
+		Logger::log('Switch contact ' . $cid . ' (' . $url . ') for user ' . $uid . ' to ActivityPub');
676 663
 
677 664
 		// Send a new follow request to be sure that the connection still exists
678 665
 		if (($uid != 0) && DBA::exists('contact', ['id' => $cid, 'rel' => [Contact::SHARING, Contact::FRIEND]])) {
679
-			ActivityPub\Transmitter::sendActivity('Follow', $profile['url'], $uid);
680
-			Logger::log('Send a new follow request to ' . $profile['url'] . ' for user ' . $uid, Logger::DEBUG);
666
+			ActivityPub\Transmitter::sendActivity('Follow', $url, $uid);
667
+			Logger::log('Send a new follow request to ' . $url . ' for user ' . $uid, Logger::DEBUG);
681 668
 		}
682 669
 	}
683 670
 

Loading…
Cancel
Save