]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/PortableContact.php
Add support for multiple Link as urls of Images in ActivityPub\Receiver
[friendica.git] / src / Protocol / PortableContact.php
index 58b9d738746e2debd3c55233d6420e055b9fd520..d66676cac5699eb0fac6e802bd5717a5685a3535 100644 (file)
@@ -1,10 +1,22 @@
 <?php
 /**
- * @file src/Protocol/PortableContact.php
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  *
- * @todo Move GNU Social URL schemata (http://server.tld/user/number) to http://server.tld/username
- * @todo Fetch profile data from profile page for Redmatrix users
- * @todo Detect if it is a forum
  */
 
 namespace Friendica\Protocol;
@@ -22,6 +34,12 @@ use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
 use Friendica\Util\Strings;
 
+/**
+ *
+ * @todo Move GNU Social URL schemata (http://server.tld/user/number) to http://server.tld/username
+ * @todo Fetch profile data from profile page for Redmatrix users
+ * @todo Detect if it is a forum
+ */
 class PortableContact
 {
        const DISABLED = 0;
@@ -81,7 +99,7 @@ class PortableContact
                        return;
                }
 
-               $url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation' : '?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation');
+               $url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,contactType,generation' : '?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,contactType,generation');
 
                Logger::log('load: ' . $url, Logger::DEBUG);
 
@@ -98,7 +116,7 @@ class PortableContact
 
                $j = json_decode($s, true);
 
-               Logger::log('load: json: ' . print_r($j, true), Logger::DATA);
+               Logger::debug('load', ['json'  => $j]);
 
                if (!isset($j['entry'])) {
                        return;
@@ -116,7 +134,6 @@ class PortableContact
                        $location = '';
                        $about = '';
                        $keywords = '';
-                       $gender = '';
                        $contact_type = -1;
                        $generation = 0;
 
@@ -161,10 +178,6 @@ class PortableContact
                                $about = HTML::toBBCode($entry['aboutMe']);
                        }
 
-                       if (isset($entry['gender'])) {
-                               $gender = $entry['gender'];
-                       }
-
                        if (isset($entry['generation']) && ($entry['generation'] > 0)) {
                                $generation = ++$entry['generation'];
                        }
@@ -185,7 +198,6 @@ class PortableContact
                                        "photo" => $profile_photo,
                                        "about" => $about,
                                        "location" => $location,
-                                       "gender" => $gender,
                                        "keywords" => $keywords,
                                        "connect" => $connect_url,
                                        "updated" => $updated,
@@ -216,7 +228,7 @@ class PortableContact
        {
                $r = q(
                        "SELECT `url`, `site_name` AS `displayName`, `network`, `platform`, `version` FROM `gserver`
-                       WHERE `network` IN ('%s', '%s', '%s') AND `last_contact` > `last_failure`
+                       WHERE `network` IN ('%s', '%s', '%s') AND NOT `failed`
                        ORDER BY `last_contact`
                        LIMIT 1000",
                        DBA::escape(Protocol::DFRN),
@@ -275,7 +287,7 @@ class PortableContact
                self::fetchServerlist($server["poco"]);
 
                // Fetch all users from the other server
-               $url = $server["poco"] . "/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation";
+               $url = $server["poco"] . "/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,contactType,generation";
 
                Logger::info("Fetch all users from the server " . $server["url"]);
 
@@ -298,7 +310,7 @@ class PortableContact
                                $updatedSince = date(DateTimeFormat::MYSQL, time() - $timeframe * 86400);
 
                                // Fetch all global contacts from the other server (Not working with Redmatrix and Friendica versions before 3.3)
-                               $url = $server["poco"]."/@global?updatedSince=".$updatedSince."&fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation";
+                               $url = $server["poco"]."/@global?updatedSince=".$updatedSince."&fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,contactType,generation";
 
                                $success = false;
 
@@ -358,7 +370,7 @@ class PortableContact
                                Logger::log('Fetch contacts for the user ' . $username . ' from the server ' . $server['nurl'], Logger::DEBUG);
 
                                // Fetch all contacts from a given user from the other server
-                               $url = $server['poco'] . '/' . $username . '/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation';
+                               $url = $server['poco'] . '/' . $username . '/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,contactType,generation';
 
                                $curlResult = Network::curl($url);
 
@@ -391,7 +403,6 @@ class PortableContact
                        $location = '';
                        $about = '';
                        $keywords = '';
-                       $gender = '';
                        $contact_type = -1;
                        $generation = $default_generation;
 
@@ -437,10 +448,6 @@ class PortableContact
                                $about = HTML::toBBCode($entry['aboutMe']);
                        }
 
-                       if (isset($entry['gender'])) {
-                               $gender = $entry['gender'];
-                       }
-
                        if (isset($entry['generation']) && ($entry['generation'] > 0)) {
                                $generation = ++$entry['generation'];
                        }
@@ -466,7 +473,6 @@ class PortableContact
                                                "photo" => $profile_photo,
                                                "about" => $about,
                                                "location" => $location,
-                                               "gender" => $gender,
                                                "keywords" => $keywords,
                                                "connect" => $connect_url,
                                                "updated" => $updated,