More avatar handling isolation

This commit is contained in:
Michael 2022-05-09 06:57:47 +00:00
parent 681d19a3bc
commit 006b7a95f0
2 changed files with 7 additions and 3 deletions

View File

@ -129,7 +129,7 @@ class Avatar
* @param string $avatar * @param string $avatar
* @return boolean * @return boolean
*/ */
public static function isCacheFile(string $avatar): bool private static function isCacheFile(string $avatar): bool
{ {
return !empty(self::getCacheFile($avatar)); return !empty(self::getCacheFile($avatar));
} }

View File

@ -1581,8 +1581,12 @@ class Contact
self::updateAvatar($cid, $contact['avatar'], true); self::updateAvatar($cid, $contact['avatar'], true);
return; return;
} }
} elseif (!Avatar::isCacheFile($contact['photo']) || !Avatar::isCacheFile($contact['thumb']) || !Avatar::isCacheFile($contact['micro'])) { } elseif (Photo::isPhotoURI($contact['photo']) || Photo::isPhotoURI($contact['thumb']) || Photo::isPhotoURI($contact['micro'])) {
Logger::info('Removing/replacing avatar cache', ['id' => $cid, 'contact' => $contact]); Logger::info('Replacing legacy avatar cache', ['id' => $cid, 'contact' => $contact]);
self::updateAvatar($cid, $contact['avatar'], true);
return;
} elseif (DI::config()->get('system', 'avatar_cache') && (empty($contact['photo']) || empty($contact['thumb']) || empty($contact['micro']))) {
Logger::info('Adding avatar cache file', ['id' => $cid, 'contact' => $contact]);
self::updateAvatar($cid, $contact['avatar'], true); self::updateAvatar($cid, $contact['avatar'], true);
return; return;
} }