Centralized gsid generation

This commit is contained in:
Michael 2020-05-22 10:10:24 +00:00
parent a77b7793a8
commit e27915a819
3 changed files with 10 additions and 14 deletions

View 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;

View 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;
}

View 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) {