]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Contact.php
Use rawContent for Special Options to avoid a protected options() method
[friendica.git] / src / Model / Contact.php
index 4898ec56783e57368fab52a946457eeacb5f9d1b..ee905a80d38afc99b75a004d8fea779e6fa4b6b5 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -211,6 +211,19 @@ class Contact
                return DBA::selectFirst('contact', $fields, ['id' => $id]);
        }
 
+       /**
+        * Fetch the first contact with the provided uri-id.
+        *
+        * @param integer $uri_id uri-id of the contact
+        * @param array   $fields Array of selected fields, empty for all
+        * @return array|boolean Contact record if it exists, false otherwise
+        * @throws \Exception
+        */
+       public static function getByUriId($uri_id, $fields = [])
+       {
+               return DBA::selectFirst('contact', $fields, ['uri-id' => $uri_id], ['order' => ['uid']]);
+       }
+
        /**
         * Fetches a contact by a given url
         *
@@ -1228,6 +1241,10 @@ class Contact
                        Logger::info('Contact will be updated', ['url' => $url, 'uid' => $uid, 'update' => $update, 'cid' => $contact_id]);
                }
 
+               if ($data['network'] == Protocol::DIASPORA) {
+                       FContact::updateFromProbeArray($data);
+               }
+
                self::updateFromProbeArray($contact_id, $data);
 
                // Don't return a number for a deleted account
@@ -2063,6 +2080,11 @@ class Contact
                }
 
                $ret = Probe::uri($contact['url'], $network, $contact['uid']);
+
+               if ($ret['network'] == Protocol::DIASPORA) {
+                       FContact::updateFromProbeArray($ret);
+               }
+
                return self::updateFromProbeArray($id, $ret);
        }