]> git.mxchange.org Git - friendica.git/commitdiff
Merge remote-tracking branch 'upstream/2018.08-rc' into ap1
authorMichael <heluecht@pirati.ca>
Sat, 15 Sep 2018 20:49:46 +0000 (20:49 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 15 Sep 2018 20:49:46 +0000 (20:49 +0000)
1  2 
mod/contacts.php
src/Network/Probe.php
src/Protocol/Diaspora.php
src/Protocol/PortableContact.php

diff --combined mod/contacts.php
index 031f6964c3be9cd91c827489d8b52439af869299,1604f0b6605ec43d6f0e936972ad2394a45c11f2..a7c67cb910aa2964e456d967448a9040731eb34c
@@@ -47,6 -47,11 +47,11 @@@ function contacts_init(App $a
                if (!DBA::isResult($contact)) {
                        $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => 0]);
                }
+               // Don't display contacts that are about to be deleted
+               if ($contact['network'] == Protocol::PHANTOM) {
+                       $contact = false;
+               }
        }
  
        if (DBA::isResult($contact)) {
@@@ -537,7 -542,7 +542,7 @@@ function contacts_content(App $a, $upda
                        $relation_text = '';
                }
  
 -              if (!in_array($contact['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) {
 +              if (!in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) {
                        $relation_text = "";
                }
  
                }
                $lblsuggest = (($contact['network'] === Protocol::DFRN) ? L10n::t('Suggest friends') : '');
  
 -              $poll_enabled = in_array($contact['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]);
 +              $poll_enabled = in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]);
  
                $nettype = L10n::t('Network type: %s', ContactSelector::networkToName($contact['network'], $contact["url"]));
  
                $sql_extra = " AND `blocked` = 0 ";
        }
  
+       $sql_extra .= sprintf(" AND `network` != '%s' ", Protocol::PHANTOM);
        $search = x($_GET, 'search') ? notags(trim($_GET['search'])) : '';
        $nets   = x($_GET, 'nets'  ) ? notags(trim($_GET['nets']))   : '';
  
@@@ -968,7 -975,7 +975,7 @@@ function contact_conversations(App $a, 
                $profiledata = Contact::getDetailsByURL($contact["url"]);
  
                if (local_user()) {
 -                      if (in_array($profiledata["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
 +                      if (in_array($profiledata["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
                                $profiledata["remoteconnect"] = System::baseUrl()."/follow?url=".urlencode($profiledata["url"]);
                        }
                }
@@@ -992,7 -999,7 +999,7 @@@ function contact_posts(App $a, $contact
                $profiledata = Contact::getDetailsByURL($contact["url"]);
  
                if (local_user()) {
 -                      if (in_array($profiledata["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
 +                      if (in_array($profiledata["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
                                $profiledata["remoteconnect"] = System::baseUrl()."/follow?url=".urlencode($profiledata["url"]);
                        }
                }
@@@ -1073,7 -1080,7 +1080,7 @@@ function _contact_detail_for_template(a
   */
  function contact_actions($contact)
  {
 -      $poll_enabled = in_array($contact['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]);
 +      $poll_enabled = in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]);
        $contact_actions = [];
  
        // Provide friend suggestion only for Friendica contacts
diff --combined src/Network/Probe.php
index 2cf91486bbdd8428ac51f07c1a8061163c478198,75231f44ff0bc9e2e1061704cdcbdecc1df1783a..0e9219c5a615b8b095f1068b827f060f640d27c4
@@@ -19,7 -19,6 +19,7 @@@ use Friendica\Model\Contact
  use Friendica\Model\Profile;
  use Friendica\Protocol\Email;
  use Friendica\Protocol\Feed;
 +use Friendica\Protocol\ActivityPub;
  use Friendica\Util\Crypto;
  use Friendica\Util\DateTimeFormat;
  use Friendica\Util\Network;
@@@ -329,18 -328,7 +329,18 @@@ class Prob
                        $uid = local_user();
                }
  
 -              $data = self::detect($uri, $network, $uid);
 +              if ($network != Protocol::ACTIVITYPUB) {
 +                      $data = self::detect($uri, $network, $uid);
 +              } else {
 +                      $data = null;
 +              }
 +
 +              if (in_array(defaults($data, 'network', ''), ['', Protocol::PHANTOM])) {
 +                      $ap_profile = ActivityPub::fetchProfile($uri);
 +                      if (!empty($ap_profile) && ($ap_profile['network'] == Protocol::ACTIVITYPUB)) {
 +                              $data = $ap_profile;
 +                      }
 +              }
  
                if (!isset($data["url"])) {
                        $data["url"] = $uri;
                $hcard_url = "";
                $data = [];
                foreach ($webfinger["links"] as $link) {
-                       if (($link["rel"] == NAMESPACE_DFRN) && ($link["href"] != "")) {
+                       if (($link["rel"] == NAMESPACE_DFRN) && !empty($link["href"])) {
                                $data["network"] = Protocol::DFRN;
-                       } elseif (($link["rel"] == NAMESPACE_FEED) && ($link["href"] != "")) {
+                       } elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) {
                                $data["poll"] = $link["href"];
-                       } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && ($link["type"] == "text/html") && ($link["href"] != "")) {
+                       } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (defaults($link, "type", "") == "text/html") && !empty($link["href"])) {
                                $data["url"] = $link["href"];
-                       } elseif (($link["rel"] == "http://microformats.org/profile/hcard") && ($link["href"] != "")) {
+                       } elseif (($link["rel"] == "http://microformats.org/profile/hcard") && !empty($link["href"])) {
                                $hcard_url = $link["href"];
-                       } elseif (($link["rel"] == NAMESPACE_POCO) && ($link["href"] != "")) {
+                       } elseif (($link["rel"] == NAMESPACE_POCO) && !empty($link["href"])) {
                                $data["poco"] = $link["href"];
-                       } elseif (($link["rel"] == "http://webfinger.net/rel/avatar") && ($link["href"] != "")) {
+                       } elseif (($link["rel"] == "http://webfinger.net/rel/avatar") && !empty($link["href"])) {
                                $data["photo"] = $link["href"];
-                       } elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && ($link["href"] != "")) {
+                       } elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && !empty($link["href"])) {
                                $data["baseurl"] = trim($link["href"], '/');
-                       } elseif (($link["rel"] == "http://joindiaspora.com/guid") && ($link["href"] != "")) {
+                       } elseif (($link["rel"] == "http://joindiaspora.com/guid") && !empty($link["href"])) {
                                $data["guid"] = $link["href"];
-                       } elseif (($link["rel"] == "diaspora-public-key") && ($link["href"] != "")) {
+                       } elseif (($link["rel"] == "diaspora-public-key") && !empty($link["href"])) {
                                $data["pubkey"] = base64_decode($link["href"]);
  
                                //if (strstr($data["pubkey"], 'RSA ') || ($link["type"] == "RSA"))
                $hcard_url = "";
                $data = [];
                foreach ($webfinger["links"] as $link) {
-                       if (($link["rel"] == "http://microformats.org/profile/hcard") && ($link["href"] != "")) {
+                       if (($link["rel"] == "http://microformats.org/profile/hcard") && !empty($link["href"])) {
                                $hcard_url = $link["href"];
-                       } elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && ($link["href"] != "")) {
+                       } elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && !empty($link["href"])) {
                                $data["baseurl"] = trim($link["href"], '/');
-                       } elseif (($link["rel"] == "http://joindiaspora.com/guid") && ($link["href"] != "")) {
+                       } elseif (($link["rel"] == "http://joindiaspora.com/guid") && !empty($link["href"])) {
                                $data["guid"] = $link["href"];
-                       } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && ($link["type"] == "text/html") && ($link["href"] != "")) {
+                       } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (defaults($link, "type", "") == "text/html") && !empty($link["href"])) {
                                $data["url"] = $link["href"];
-                       } elseif (($link["rel"] == NAMESPACE_FEED) && ($link["href"] != "")) {
+                       } elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) {
                                $data["poll"] = $link["href"];
-                       } elseif (($link["rel"] == NAMESPACE_POCO) && ($link["href"] != "")) {
+                       } elseif (($link["rel"] == NAMESPACE_POCO) && !empty($link["href"])) {
                                $data["poco"] = $link["href"];
-                       } elseif (($link["rel"] == "salmon") && ($link["href"] != "")) {
+                       } elseif (($link["rel"] == "salmon") && !empty($link["href"])) {
                                $data["notify"] = $link["href"];
-                       } elseif (($link["rel"] == "diaspora-public-key") && ($link["href"] != "")) {
+                       } elseif (($link["rel"] == "diaspora-public-key") && !empty($link["href"])) {
                                $data["pubkey"] = base64_decode($link["href"]);
  
                                //if (strstr($data["pubkey"], 'RSA ') || ($link["type"] == "RSA"))
                if (is_array($webfinger["links"])) {
                        foreach ($webfinger["links"] as $link) {
                                if (($link["rel"] == "http://webfinger.net/rel/profile-page")
-                                       && ($link["type"] == "text/html")
+                                       && (defaults($link, "type", "") == "text/html")
                                        && ($link["href"] != "")
                                ) {
                                        $data["url"] = $link["href"];
-                               } elseif (($link["rel"] == "salmon") && ($link["href"] != "")) {
+                               } elseif (($link["rel"] == "salmon") && !empty($link["href"])) {
                                        $data["notify"] = $link["href"];
-                               } elseif (($link["rel"] == NAMESPACE_FEED) && ($link["href"] != "")) {
+                               } elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) {
                                        $data["poll"] = $link["href"];
-                               } elseif (($link["rel"] == "magic-public-key") && ($link["href"] != "")) {
+                               } elseif (($link["rel"] == "magic-public-key") && !empty($link["href"])) {
                                        $pubkey = $link["href"];
  
                                        if (substr($pubkey, 0, 5) === 'data:') {
                $data = [];
                foreach ($webfinger["links"] as $link) {
                        if (($link["rel"] == "http://webfinger.net/rel/profile-page")
-                               && ($link["type"] == "text/html")
+                               && (defaults($link, "type", "") == "text/html")
                                && ($link["href"] != "")
                        ) {
                                $data["url"] = $link["href"];
index 11a0e5996e983e8a31bb77cd45a8259149419a96,27cfdccd853af83b89d026ddaf6fb5e741e25605..e7edcdc490a9363d693d502bec5d29df73006af1
@@@ -1592,13 -1592,17 +1592,13 @@@ class Diaspor
                if (DBA::isResult($item)) {
                        return $item["uri"];
                } elseif (!$onlyfound) {
 -                      $contact = Contact::getDetailsByAddr($author, 0);
 -                      if (!empty($contact['network'])) {
 -                              $prefix = 'urn:X-' . $contact['network'] . ':';
 -                      } else {
 -                              // This fallback should happen most unlikely
 -                              $prefix = 'urn:X-dspr:';
 -                      }
 +                      $person = self::personByHandle($author);
  
 -                      $author_parts = explode('@', $author);
 +                      $parts = parse_url($person['url']);
 +                      unset($parts['path']);
 +                      $host_url = Network::unparseURL($parts);
  
 -                      return $prefix . $author_parts[1] . ':' . $author_parts[0] . ':'. $guid;
 +                      return $host_url . '/object/' . $guid;
                }
  
                return "";
  
                $myaddr = self::myHandle($owner);
  
-               $public = (($item["private"]) ? "false" : "true");
+               $public = ($item["private"] ? "false" : "true");
  
                $created = DateTimeFormat::utc($item["created"], DateTimeFormat::ATOM);
  
index 61274dc2be86a1e24951b21d9799f6e1b36e7a4a,2939f69e55c2cbe42727cd76e7b41952df811bda..280dbe72c2a2afe151b5c5d47dd8e11a561fc182
@@@ -333,7 -333,7 +333,7 @@@ class PortableContac
                        $server_url = normalise_link(self::detectServer($profile));
                }
  
 -              if (!in_array($gcontacts[0]["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::FEED, Protocol::OSTATUS, ""])) {
 +              if (!in_array($gcontacts[0]["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::FEED, Protocol::OSTATUS, ""])) {
                        logger("Profile ".$profile.": Network type ".$gcontacts[0]["network"]." can't be checked", LOGGER_DEBUG);
                        return false;
                }
  
                                if (isset($data['version'])) {
                                        $platform = "Mastodon";
-                                       $version = $data['version'];
-                                       $site_name = $data['title'];
-                                       $info = $data['description'];
+                                       $version = defaults($data, 'version', '');
+                                       $site_name = defaults($data, 'title', '');
+                                       $info = defaults($data, 'description', '');
                                        $network = Protocol::OSTATUS;
                                }