Contact\User::insertForContactArray($contact);
+ if ((empty($contact['baseurl']) || empty($contact['gsid'])) && Probe::isProbable($contact['network'])) {
+ Logger::debug('Update missing baseurl', ['id' => $contact['id'], 'url' => $contact['url'], 'callstack' => System::callstack(4, 0, true)]);
+ UpdateContact::add(['priority' => Worker::PRIORITY_MEDIUM, 'dont_fork' => true], $contact['id']);
+ }
+
return $contact['id'];
}
$fields = [
'uid' => $uid,
'url' => $data['url'],
+ 'baseurl' => $data['baseurl'] ?? '',
'nurl' => Strings::normaliseLink($data['url']),
'network' => $data['network'],
'created' => DateTimeFormat::utcNow(),
return false;
}
- $fields = ['id', 'url', 'name', 'nick', 'avatar', 'photo', 'network', 'blocked'];
+ $fields = ['id', 'url', 'name', 'nick', 'avatar', 'photo', 'network', 'blocked', 'baseurl'];
$pub_contact = DBA::selectFirst('contact', $fields, ['id' => $datarray['author-id']]);
if (!DBA::isResult($pub_contact)) {
// Should never happen
'created' => DateTimeFormat::utcNow(),
'url' => $url,
'nurl' => Strings::normaliseLink($url),
+ 'baseurl' => $pub_contact['baseurl'] ?? '',
'name' => $name,
'nick' => $nick,
'network' => $network,
}
}
- if (!empty($data['baseurl']) && empty($data['gsid'])) {
- $data['gsid'] = GServer::getID($data['baseurl']);
- }
-
if (empty($data['network'])) {
$data['network'] = Protocol::PHANTOM;
}
+ $baseurl = parse_url($data['url'], PHP_URL_SCHEME) . '://' . parse_url($data['url'], PHP_URL_HOST);
+ if (empty($data['baseurl']) && ($data['network'] == Protocol::ACTIVITYPUB) && (rtrim($data['url'], '/') == $baseurl)) {
+ $data['baseurl'] = $baseurl;
+ }
+
+ if (!empty($data['baseurl']) && empty($data['gsid'])) {
+ $data['gsid'] = GServer::getID($data['baseurl']);
+ }
+
// Ensure that local connections always are DFRN
if (($network == '') && ($data['network'] != Protocol::PHANTOM) && (self::ownHost($data['baseurl'] ?? '') || self::ownHost($data['url']))) {
$data['network'] = Protocol::DFRN;