]> git.mxchange.org Git - friendica.git/commitdiff
Centralized gsid generation
authorMichael <heluecht@pirati.ca>
Fri, 22 May 2020 10:10:24 +0000 (10:10 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 22 May 2020 10:10:24 +0000 (10:10 +0000)
src/Model/Contact.php
src/Network/Probe.php
src/Protocol/ActivityPub.php

index f611cc452f0861d1bcd96fc51fe3800f797025b8..ee49d9b75ceadf9d8605ff8db87e16d9d93dc232 100644 (file)
@@ -1530,10 +1530,6 @@ class Contact
 
                if (empty($data)) {
                        $data = Probe::uri($url, "", $uid);
-                       // Ensure that there is a gserver entry
-                       if (!empty($data['baseurl']) && ($data['network'] != Protocol::PHANTOM)) {
-                               $data['gsid'] = GServer::getID($data['baseurl']);
-                       }
                }
 
                // Take the default values when probing failed
@@ -2136,10 +2132,6 @@ class Contact
                        }
                }
 
-               if (!empty($ret['baseurl']) && empty($contact['gsid'])) {
-                       $ret['gsid'] = GServer::getID($ret['baseurl']);
-               }
-
                $new_pubkey = $ret['pubkey'];
 
                $update = false;
@@ -2308,10 +2300,6 @@ class Contact
                        $ret = Probe::uri($url, $network, $uid, false);
                }
 
-               if (!empty($ret['baseurl'])) {
-                       $ret['gsid'] = GServer::getID($ret['baseurl']);
-               }
-
                if (($network != '') && ($ret['network'] != $network)) {
                        Logger::log('Expected network ' . $network . ' does not match actual network ' . $ret['network']);
                        return $result;
index edcb9f4c342c0e2989d605ec64a9e22a425b7e5f..5872ae587b53fe84efd4248699a98a2d9cf5c064 100644 (file)
@@ -30,6 +30,7 @@ use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
+use Friendica\Model\GServer;
 use Friendica\Model\Profile;
 use Friendica\Protocol\ActivityNamespace;
 use Friendica\Protocol\ActivityPub;
@@ -86,14 +87,16 @@ class Probe
                                "community", "keywords", "location", "about", "hide",
                                "batch", "notify", "poll", "request", "confirm", "poco",
                                "following", "followers", "inbox", "outbox", "sharedinbox",
-                               "priority", "network", "pubkey", "baseurl"];
+                               "priority", "network", "pubkey", "baseurl", "gsid"];
 
                $newdata = [];
                foreach ($fields as $field) {
                        if (isset($data[$field])) {
                                $newdata[$field] = $data[$field];
-                       } else {
+                       } elseif ($field != "gsid") {
                                $newdata[$field] = "";
+                       } else {
+                               $newdata[$field] = null;
                        }
                }
 
@@ -461,6 +464,10 @@ class Probe
                        $data['baseurl'] = self::$baseurl;
                }
 
+               if (!empty($data['baseurl']) && empty($data['gsid'])) {
+                       $data['gsid'] = GServer::getID($data['baseurl']);
+               }
+
                if (empty($data['network'])) {
                        $data['network'] = Protocol::PHANTOM;
                }
index c3168f5509f98b3f5fc7ab6477f81cc32bb97d7e..9d6223a748d4d090d060ef3c97a037c70635a4e3 100644 (file)
@@ -171,6 +171,7 @@ class ActivityPub
                $profile['poll'] = $apcontact['outbox'];
                $profile['pubkey'] = $apcontact['pubkey'];
                $profile['baseurl'] = $apcontact['baseurl'];
+               $profile['gsid'] = $apcontact['gsid'];
 
                // Remove all "null" fields
                foreach ($profile as $field => $content) {