From ab1ff53b18f24a532c89c295940ed500853507d5 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 10 Dec 2022 15:59:11 +0000 Subject: [PATCH] Diaspora added to localprobe --- src/Network/Probe.php | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/Network/Probe.php b/src/Network/Probe.php index e74b437345..8a8e1a01f1 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -38,6 +38,7 @@ use Friendica\Network\HTTPClient\Client\HttpClientAccept; use Friendica\Network\HTTPClient\Client\HttpClientOptions; use Friendica\Protocol\ActivityNamespace; use Friendica\Protocol\ActivityPub; +use Friendica\Protocol\Diaspora; use Friendica\Protocol\Email; use Friendica\Protocol\Feed; use Friendica\Protocol\Salmon; @@ -358,7 +359,9 @@ class Probe if (empty($data) || (!empty($ap_profile) && empty($network) && (($data['network'] ?? '') != Protocol::DFRN))) { $networks = $data['networks'] ?? []; unset($data['networks']); - $networks[$data['network']] = $data; + if (!empty($data['network'])) { + $networks[$data['network']] = $data; + } $data = $ap_profile; $data['networks'] = $networks; } elseif (!empty($ap_profile)) { @@ -2207,6 +2210,10 @@ class Probe $owner = User::getOwnerDataById($uid); $approfile = ActivityPub\Transmitter::getProfile($uid); + $split_name = Diaspora::splitName($owner['name']); + $firstname = $split_name['first']; + $lastname = $split_name['last']; + if (empty($owner['gsid'])) { $owner['gsid'] = GServer::getID($approfile['generator']['url']); } @@ -2226,7 +2233,28 @@ class Probe 'inbox' => $approfile['inbox'], 'outbox' => $approfile['outbox'], 'sharedinbox' => $approfile['endpoints']['sharedInbox'], 'network' => Protocol::DFRN, 'pubkey' => $owner['upubkey'], 'baseurl' => $approfile['generator']['url'], 'gsid' => $owner['gsid'], - 'manually-approve' => in_array($owner['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP]) + 'manually-approve' => in_array($owner['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP]), + 'networks' => [ + Protocol::DIASPORA => [ + 'name' => $owner['name'], + 'given_name' => $firstname, + 'family_name' => $lastname, + 'nick' => $owner['nick'], + 'guid' => $approfile['diaspora:guid'], + 'url' => $owner['url'], + 'addr' => $owner['addr'], + 'alias' => $owner['alias'], + 'photo' => $owner['photo'], + 'photo_medium' => $owner['thumb'], + 'photo_small' => $owner['micro'], + 'batch' => $approfile['generator']['url'] . '/receive/public', + 'notify' => $owner['notify'], + 'poll' => $owner['poll'], + 'poco' => $owner['poco'], + 'network' => Protocol::DIASPORA, + 'pubkey' => $owner['upubkey'], + ] + ] ]; } catch (Exception $e) { // Default values for non existing targets -- 2.39.5