]> git.mxchange.org Git - friendica.git/commitdiff
Diaspora added to localprobe
authorMichael <heluecht@pirati.ca>
Sat, 10 Dec 2022 15:59:11 +0000 (15:59 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 10 Dec 2022 15:59:11 +0000 (15:59 +0000)
src/Network/Probe.php

index e74b4373454b4403ef0d275a6c047ce9b6de169f..8a8e1a01f1e7aa6a60fe38f3da28deea937e37dd 100644 (file)
@@ -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