Merge pull request #8044 from annando/contact-adding

Don't add contacts when not needed
This commit is contained in:
Philipp 2020-01-01 20:38:34 +01:00 committed by GitHub
commit 75c74e8562
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 52 additions and 19 deletions

View file

@ -269,29 +269,37 @@ class Contact
* @brief Get the basepath for a given contact link
*
* @param string $url The contact link
* @param boolean $dont_update Don't update the contact
*
* @return string basepath
* @return boolean $dont_update Don't update the contact
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
public static function getBasepath($url, $dont_update = false)
{
$contact = DBA::selectFirst('contact', ['baseurl'], ['uid' => 0, 'nurl' => Strings::normaliseLink($url)]);
$contact = DBA::selectFirst('contact', ['id', 'baseurl'], ['uid' => 0, 'nurl' => Strings::normaliseLink($url)]);
if (!DBA::isResult($contact)) {
return '';
}
if (!empty($contact['baseurl'])) {
return $contact['baseurl'];
} elseif ($dont_update) {
return '';
}
self::updateFromProbeByURL($url, true);
// Update the existing contact
self::updateFromProbe($contact['id'], '', true);
$contact = DBA::selectFirst('contact', ['baseurl'], ['uid' => 0, 'nurl' => Strings::normaliseLink($url)]);
if (!empty($contact['baseurl'])) {
return $contact['baseurl'];
// And fetch the result
$contact = DBA::selectFirst('contact', ['baseurl'], ['id' => $contact['id']]);
if (empty($contact['baseurl'])) {
Logger::info('No baseurl for contact', ['url' => $url]);
return '';
}
return '';
Logger::info('Found baseurl for contact', ['url' => $url, 'baseurl' => $contact['baseurl']]);
return $contact['baseurl'];
}
/**