Merge pull request #8684 from annando/baseurl

Some more "baseurl" improvements
This commit is contained in:
Hypolite Petovan 2020-05-24 17:34:14 -04:00 committed by GitHub
commit 609ae1869c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View File

@ -1542,6 +1542,14 @@ class Contact
return 0; return 0;
} }
if (!empty($data['baseurl'])) {
$data['baseurl'] = GServer::cleanURL($data['baseurl']);
}
if (!empty($data['baseurl']) && empty($data['gsid'])) {
$data['gsid'] = GServer::getID($data['baseurl']);
}
if (!$contact_id && !empty($data['alias']) && ($data['alias'] != $url) && !$in_loop) { if (!$contact_id && !empty($data['alias']) && ($data['alias'] != $url) && !$in_loop) {
$contact_id = self::getIdForURL($data["alias"], $uid, true, $default, true); $contact_id = self::getIdForURL($data["alias"], $uid, true, $default, true);
} }
@ -1624,7 +1632,7 @@ class Contact
} }
} }
} else { } else {
$fields = ['url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date', 'baseurl']; $fields = ['url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date', 'baseurl', 'gsid'];
$contact = DBA::selectFirst('contact', $fields, ['id' => $contact_id]); $contact = DBA::selectFirst('contact', $fields, ['id' => $contact_id]);
// This condition should always be true // This condition should always be true
@ -1638,7 +1646,7 @@ class Contact
'updated' => DateTimeFormat::utcNow() 'updated' => DateTimeFormat::utcNow()
]; ];
$fields = ['addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'baseurl']; $fields = ['addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'baseurl', 'gsid'];
foreach ($fields as $field) { foreach ($fields as $field) {
$updated[$field] = ($data[$field] ?? '') ?: $contact[$field]; $updated[$field] = ($data[$field] ?? '') ?: $contact[$field];

View File

@ -436,9 +436,7 @@ class Probe
$data['url'] = $uri; $data['url'] = $uri;
} }
if (!empty($data['photo']) && !empty($data['baseurl'])) { if (empty($data['photo'])) {
$data['baseurl'] = Network::getUrlMatch(Strings::normaliseLink($data['baseurl']), Strings::normaliseLink($data['photo']));
} elseif (empty($data['photo'])) {
$data['photo'] = DI::baseUrl() . '/images/person-300.jpg'; $data['photo'] = DI::baseUrl() . '/images/person-300.jpg';
} }