Merge pull request #11496 from annando/no-local-update

Don't update the local avatar
This commit is contained in:
Hypolite Petovan 2022-05-11 14:53:25 -04:00 committed by GitHub
commit f128c00ca5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1575,6 +1575,10 @@ class Contact
return; return;
} }
if (Network::isLocalLink($contact['url'])) {
return;
}
if (in_array($contact['network'], [Protocol::FEED, Protocol::MAIL]) || DI::config()->get('system', 'cache_contact_avatar')) { if (in_array($contact['network'], [Protocol::FEED, Protocol::MAIL]) || DI::config()->get('system', 'cache_contact_avatar')) {
if (!empty($contact['avatar']) && (empty($contact['photo']) || empty($contact['thumb']) || empty($contact['micro']))) { if (!empty($contact['avatar']) && (empty($contact['photo']) || empty($contact['thumb']) || empty($contact['micro']))) {
Logger::info('Adding avatar cache', ['id' => $cid, 'contact' => $contact]); Logger::info('Adding avatar cache', ['id' => $cid, 'contact' => $contact]);
@ -1690,7 +1694,9 @@ class Contact
return $contact; return $contact;
} }
if (!empty($contact['id']) && !empty($contact['avatar'])) { $local = !empty($contact['url']) && Network::isLocalLink($contact['url']);
if (!$local && !empty($contact['id']) && !empty($contact['avatar'])) {
self::updateAvatar($contact['id'], $contact['avatar'], true); self::updateAvatar($contact['id'], $contact['avatar'], true);
$new_contact = self::getById($contact['id'], $contact_fields); $new_contact = self::getById($contact['id'], $contact_fields);
@ -1698,9 +1704,7 @@ class Contact
// We only update the cache fields // We only update the cache fields
$contact = array_merge($contact, $new_contact); $contact = array_merge($contact, $new_contact);
} }
} } elseif ($local && !empty($contact['avatar'])) {
if (!empty($contact['avatar']) && !empty($contact['url']) && Network::isLocalLink($contact['url'])) {
return $contact; return $contact;
} }