X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FActivityPub%2FReceiver.php;h=bb676b396e338113ee517be084f8dfde49ec994e;hb=15535811752e5b3cb548dcbe1abe5d9c98c276b0;hp=a8b5a18db10136a78c01ad15961b479ae3b5f508;hpb=a248da8f2e720243702426d27e9394ddbac9d0d2;p=friendica.git diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index a8b5a18db1..bb676b396e 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -386,15 +386,14 @@ class Receiver case 'as:Announce': if (in_array($object_data['object_type'], self::CONTENT_TYPES)) { $profile = APContact::getByURL($object_data['actor']); - if ($profile['type'] == 'Person') { - // Reshared posts from persons appear as summary at the bottom - // If this isn't set, then a single reshare appears on top. This is used for groups. - $object_data['thread-completion'] = true; - } + // Reshared posts from persons appear as summary at the bottom + // If this isn't set, then a single reshare appears on top. This is used for groups. + $object_data['thread-completion'] = ($profile['type'] != 'Group'); + ActivityPub\Processor::createItem($object_data); // Add the bottom reshare information only for persons - if ($profile['type'] == 'Person') { + if ($profile['type'] != 'Group') { $announce_object_data = self::processObject($activity); $announce_object_data['name'] = $type; $announce_object_data['author'] = JsonLD::fetchElement($activity, 'as:actor', '@id'); @@ -657,27 +656,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); } }