]> git.mxchange.org Git - friendica.git/commitdiff
More avatar handling isolation
authorMichael <heluecht@pirati.ca>
Mon, 9 May 2022 06:57:47 +0000 (06:57 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 9 May 2022 06:57:47 +0000 (06:57 +0000)
src/Contact/Avatar.php
src/Model/Contact.php

index f4e5b71afefdba2e0392bf43de3bad8f314f213a..18f63b07b2bccfca79d1d344bbe116e2ee953ada 100644 (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));
        }
index c83bf1f4167d5df0fbe69bf7cfc2bad36db8214e..6a982869944de165d48124dc962040f7131e0291 100644 (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;
                }
        }