]> git.mxchange.org Git - friendica.git/commitdiff
Replaced check with hardwired path
authorMichael <heluecht@pirati.ca>
Mon, 9 May 2022 04:26:00 +0000 (04:26 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 9 May 2022 04:26:00 +0000 (04:26 +0000)
src/Content/Conversation.php
src/Model/Contact.php
src/Model/Photo.php
src/Object/Post.php

index fdb1f51d89904cfc72fcb83bd91995b62797be33..a86c7f5081c1c2a504b7c450e147254b73ed93e0 100644 (file)
@@ -37,6 +37,7 @@ use Friendica\Core\Theme;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
 use Friendica\Model\Item as ItemModel;
+use Friendica\Model\Photo;
 use Friendica\Model\Post;
 use Friendica\Model\Tag;
 use Friendica\Model\User;
@@ -672,11 +673,11 @@ class Conversation
                                                $author_thumb   = $item['author-avatar'];
                                        }
 
-                                       if (!Contact::isAvatarFile($owner_thumb)) {
+                                       if (empty($owner_thumb) || Photo::isPhotoURI($owner_thumb)) {
                                                $owner_thumb = Contact::getAvatarUrlForId($owner_avatar, Proxy::SIZE_THUMB, $owner_updated);
                                        }
-
-                                       if (!Contact::isAvatarFile($author_thumb)) {
+                       
+                                       if (empty($author_thumb) || Photo::isPhotoURI($author_thumb)) {
                                                $author_thumb = Contact::getAvatarUrlForId($author_avatar, Proxy::SIZE_THUMB, $author_updated);
                                        }
 
index f16a2e9c8aa46493a0e293ac1dffa55cc076a93b..ca286ab587ee95a084f5208f427e45a0474aa752 100644 (file)
@@ -1611,17 +1611,17 @@ class Contact
                if (DI::config()->get('system', 'avatar_cache')) {
                        switch ($size) {
                                case Proxy::SIZE_MICRO:
-                                       if (self::isAvatarFile($contact['micro'])) {
+                                       if (!empty($contact['micro']) && !Photo::isPhotoURI($contact['micro'])) {
                                                return $contact['micro'];
                                        }
                                        break;
                                case Proxy::SIZE_THUMB:
-                                       if (self::isAvatarFile($contact['thumb'])) {
+                                       if (!empty($contact['thumb']) && !Photo::isPhotoURI($contact['thumb'])) {
                                                return $contact['thumb'];
                                        }
                                        break;
                                case Proxy::SIZE_SMALL:
-                                       if (self::isAvatarFile($contact['photo'])) {
+                                       if (!empty($contact['photo']) && !Photo::isPhotoURI($contact['photo'])) {
                                                return $contact['photo'];
                                        }
                                        break;
@@ -2187,7 +2187,7 @@ class Contact
         * @param string $avatar
         * @return boolean
         */
-       public static function isAvatarFile(string $avatar): bool
+       private static function isAvatarFile(string $avatar): bool
        {
                return !empty(self::getAvatarFile($avatar));
        }
index 8583577890aa898424ae107ff44a90585028be85..6537c41d1fd81158c75b1a011b7a3127f3f52910 100644 (file)
@@ -710,6 +710,18 @@ class Photo
                return $image_uri;
        }
 
+       /**
+        * Checks if the given URL is a local photo.
+        * Since it is meant for time critical occasions, the check is done without any database requests.
+        *
+        * @param string $url
+        * @return boolean
+        */
+       public static function isPhotoURI(string $url): bool
+       {
+               return !empty(self::ridFromURI($url));
+       }
+
        /**
         * Changes photo permissions that had been embedded in a post
         *
index 0a7bea91bdd0457517d93d3d0bbccc4f46d5cc21..3c01028292d0cd2c2ecabf95c2290bf6634dd39a 100644 (file)
@@ -32,6 +32,7 @@ use Friendica\Core\Session;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\Item;
+use Friendica\Model\Photo;
 use Friendica\Model\Post as PostModel;
 use Friendica\Model\Tag;
 use Friendica\Model\User;
@@ -463,11 +464,11 @@ class Post
                        $author_thumb   = $item['author-avatar'];
                }
 
-               if (!Contact::isAvatarFile($owner_thumb)) {
+               if (empty($owner_thumb) || Photo::isPhotoURI($owner_thumb)) {
                        $owner_thumb = Contact::getAvatarUrlForId($owner_avatar, Proxy::SIZE_THUMB, $owner_updated);
                }
 
-               if (!Contact::isAvatarFile($author_thumb)) {
+               if (empty($author_thumb) || Photo::isPhotoURI($author_thumb)) {
                        $author_thumb = Contact::getAvatarUrlForId($author_avatar, Proxy::SIZE_THUMB, $author_updated);
                }