From 48087136680d345e9222c974ae983262b319d308 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 1 Feb 2022 20:22:40 +0000 Subject: [PATCH] Don't cache local avatars --- src/Model/Contact.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 9d609786e9..2afe91d134 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1913,7 +1913,14 @@ class Contact $avatar = self::getDefaultAvatar($contact, Proxy::SIZE_SMALL); } - if (in_array($contact['network'], [Protocol::FEED, Protocol::MAIL]) || DI::config()->get('system', 'cache_contact_avatar')) { + $cache_avatar = DI::config()->get('system', 'cache_contact_avatar'); + + // Local contact avatars don't need to be cached + if ($cache_avatar && Network::isLocalLink($contact['url'])) { + $cache_avatar = !DBA::exists('contact', ['nurl' => $contact['nurl'], 'self' => true]); + } + + if (in_array($contact['network'], [Protocol::FEED, Protocol::MAIL]) || $cache_avatar) { if ($default_avatar && Proxy::isLocalImage($avatar)) { $fields = ['avatar' => $avatar, 'avatar-date' => DateTimeFormat::utcNow(), 'photo' => $avatar, -- 2.39.5