]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/GContact.php
Merge pull request #5907 from nupplaphil/goaway_to_redirectto
[friendica.git] / src / Model / GContact.php
index 6f068889eebe2e96b910cd35b5e5585e231e379c..681c1c37096473fa96679edbb402086591222a67 100644 (file)
@@ -61,11 +61,11 @@ class GContact
                $search .= "%";
 
                $results = DBA::p("SELECT `nurl` FROM `gcontact`
-                       WHERE NOT `hide` AND `network` IN (?, ?, ?) AND
+                       WHERE NOT `hide` AND `network` IN (?, ?, ?, ?) AND
                                ((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) AND
                                (`addr` LIKE ? OR `name` LIKE ? OR `nick` LIKE ?) $extra_sql
                                GROUP BY `nurl` ORDER BY `nurl` DESC LIMIT 1000",
-                       Protocol::DFRN, $ostatus, $diaspora, $search, $search, $search
+                       Protocol::DFRN, Protocol::ACTIVITYPUB, $ostatus, $diaspora, $search, $search, $search
                );
 
                $gcontacts = [];
@@ -138,7 +138,7 @@ class GContact
                }
 
                // Assure that there are no parameter fragments in the profile url
-               if (in_array($gcontact['network'], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) {
+               if (in_array($gcontact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) {
                        $gcontact['url'] = self::cleanContactUrl($gcontact['url']);
                }
 
@@ -214,7 +214,7 @@ class GContact
                        throw new Exception('No name and photo for URL '.$gcontact['url']);
                }
 
-               if (!in_array($gcontact['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) {
+               if (!in_array($gcontact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) {
                        throw new Exception('No federated network ('.$gcontact['network'].') detected for URL '.$gcontact['url']);
                }
 
@@ -468,7 +468,7 @@ class GContact
                        * Uncommented because the result of the queries are to big to store it in the cache.
                        * We need to decide if we want to change the db column type or if we want to delete it.
                        */
-                       //Cache::set("suggestion_query:".$uid.":".$start.":".$limit, $r, CACHE_FIVE_MINUTES);
+                       //Cache::set("suggestion_query:".$uid.":".$start.":".$limit, $r, Cache::FIVE_MINUTES);
 
                        return $r;
                }
@@ -509,7 +509,7 @@ class GContact
                * Uncommented because the result of the queries are to big to store it in the cache.
                * We need to decide if we want to change the db column type or if we want to delete it.
                */
-               //Cache::set("suggestion_query:".$uid.":".$start.":".$limit, $list, CACHE_FIVE_MINUTES);
+               //Cache::set("suggestion_query:".$uid.":".$start.":".$limit, $list, Cache::FIVE_MINUTES);
                return $list;
        }
 
@@ -651,7 +651,7 @@ class GContact
                self::fixAlternateContactAddress($contact);
 
                // Remove unwanted parts from the contact url (e.g. "?zrl=...")
-               if (in_array($contact["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
+               if (in_array($contact["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
                        $contact["url"] = self::cleanContactUrl($contact["url"]);
                }
 
@@ -915,6 +915,11 @@ class GContact
                        intval($uid)
                );
 
+               if (!DBA::isResult($r)) {
+                       logger('Cannot find user with uid=' . $uid, LOGGER_INFO);
+                       return false;
+               }
+
                $location = Profile::formatLocation(
                        ["locality" => $r[0]["locality"], "region" => $r[0]["region"], "country-name" => $r[0]["country-name"]]
                );
@@ -952,12 +957,12 @@ class GContact
 
                $url = $server."/main/statistics";
 
-               $result = Network::curl($url);
-               if (!$result["success"]) {
+               $curlResult = Network::curl($url);
+               if (!$curlResult->isSuccess()) {
                        return false;
                }
 
-               $statistics = json_decode($result["body"]);
+               $statistics = json_decode($curlResult->getBody());
 
                if (!empty($statistics->config)) {
                        if ($statistics->config->instance_with_ssl) {