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
* @return boolean
*/
public static function isCacheFile(string $avatar): bool
private static function isCacheFile(string $avatar): bool
{
return !empty(self::getCacheFile($avatar));
}

View File

@ -1581,10 +1581,14 @@ class Contact
self::updateAvatar($cid, $contact['avatar'], true);
return;
}
} elseif (!Avatar::isCacheFile($contact['photo']) || !Avatar::isCacheFile($contact['thumb']) || !Avatar::isCacheFile($contact['micro'])) {
Logger::info('Removing/replacing avatar cache', ['id' => $cid, 'contact' => $contact]);
} elseif (Photo::isPhotoURI($contact['photo']) || Photo::isPhotoURI($contact['thumb']) || Photo::isPhotoURI($contact['micro'])) {
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);
return;
}
}