]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Contact.php
Remove unused `use` statements & remove PConfig class
[friendica.git] / src / Model / Contact.php
index 0540bf7bebd3f812a50be9da135acdbf1284c939..550f89f31a6343dad11e88fdbe36defccb5cb5cf 100644 (file)
@@ -314,6 +314,29 @@ class Contact
                return Strings::compareLink(self::getBasepath($url, true), DI::baseUrl());
        }
 
+       /**
+        * Check if the given contact ID is on the same server
+        *
+        * @param string $url The contact link
+        *
+        * @return boolean Is it the same server?
+        */
+       public static function isLocalById(int $cid)
+       {
+               $contact = DBA::selectFirst('contact', ['url', 'baseurl'], ['id' => $cid]);
+               if (!DBA::isResult($contact)) {
+                       return false;
+               }
+
+               if (empty($contact['baseurl'])) {
+                       $baseurl = self::getBasepath($contact['url'], true);
+               } else {
+                       $baseurl = $contact['baseurl'];
+               }
+
+               return Strings::compareLink($baseurl, DI::baseUrl());
+       }
+
        /**
         * Returns the public contact id of the given user id
         *
@@ -1896,6 +1919,14 @@ class Contact
                        $data = [$contact["photo"], $contact["thumb"], $contact["micro"]];
                }
 
+               foreach ($data as $image_uri) {
+                       $image_rid = Photo::ridFromURI($image_uri);
+                       if ($image_rid && !Photo::exists(['resource-id' => $image_rid, 'uid' => $uid])) {
+                               Logger::info('Regenerating avatar', ['contact uid' => $uid, 'cid' => $cid, 'missing photo' => $image_rid, 'avatar' => $contact['avatar']]);
+                               $force = true;
+                       }
+               }
+
                if (($contact["avatar"] != $avatar) || $force) {
                        $photos = Photo::importProfilePhoto($avatar, $uid, $cid, true);
 
@@ -2118,6 +2149,12 @@ class Contact
                        if ($force) {
                                self::updateContact($id, $uid, $ret['url'], ['last-update' => $updated, 'success_update' => $updated]);
                        }
+
+                       // Update the public contact
+                       if ($uid != 0) {
+                               self::updateFromProbeByURL($ret['url']);
+                       }
+
                        return true;
                }