]> git.mxchange.org Git - friendica.git/commitdiff
Some more checks that the gcontact table contains valid data
authorMichael Vogel <icarus@dabo.de>
Wed, 20 Apr 2016 05:00:55 +0000 (07:00 +0200)
committerMichael Vogel <icarus@dabo.de>
Wed, 20 Apr 2016 05:00:55 +0000 (07:00 +0200)
include/Scrape.php
include/socgraph.php
mod/item.php

index 84257f4811aac6e3d132af29475475c82ddd17df..542adc22abeb5aeb4564ae4e9099e411c78da25f 100644 (file)
@@ -799,6 +799,9 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
        if (substr($baseurl, -10) == "/index.php")
                $baseurl = str_replace("/index.php", "", $baseurl);
 
+       if ($network == "")
+               $network = NETWORK_PHANTOM;
+
        $baseurl = rtrim($baseurl, "/");
 
        if(strpos($url,'@') AND ($addr == "") AND ($network == NETWORK_DFRN))
@@ -846,7 +849,7 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
        }
 
        // Only store into the cache if the value seems to be valid
-       if (!in_array($result['network'], array(NETWORK_PHANTOM, ""))) {
+       if ($result['network'] != NETWORK_PHANTOM) {
                Cache::set("probe_url:".$mode.":".$original_url,serialize($result), CACHE_DAY);
 
                /// @todo temporary fix - we need a real contact update function that updates only changing fields
index 402fee859347f455d675c3cc3ac7d6a3c41ce7db..f7dd1ad93b11c02c89bb66be80451f443ccd4a08 100644 (file)
@@ -1377,6 +1377,17 @@ function clean_contact_url($url) {
         return $new_url;
 }
 
+function fix_alternate_contact_address(&$contact) {
+       if (($contact["network"] == NETWORK_OSTATUS) AND poco_alternate_ostatus_url($contact["url"])) {
+               $data = probe_url($contact["url"]);
+               if (!in_array($contact["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) {
+                       $contact["url"] = $data["url"];
+                       $contact["addr"] = $data["addr"];
+                       $contact["server_url"] = $data["baseurl"];
+               }
+       }
+}
+
 /**
  * @brief Fetch the gcontact id, add an entry if not existed
  *
@@ -1387,12 +1398,15 @@ function get_gcontact_id($contact) {
 
        $gcontact_id = 0;
 
-       if ($contact["network"] == NETWORK_PHANTOM)
+       if (in_array($contact["network"], array(NETWORK_FEED, NETWORK_PHANTOM)))
                return false;
 
        if ($contact["network"] == NETWORK_STATUSNET)
                $contact["network"] = NETWORK_OSTATUS;
 
+       // Replace alternate OStatus user format with the primary one
+       fix_alternate_contact_address($contact);
+
        // Remove unwanted parts from the contact url (e.g. "?zrl=...")
        $contact["url"] = clean_contact_url($contact["url"]);
 
@@ -1477,6 +1491,9 @@ function update_gcontact($contact) {
        if ($contact["network"] == NETWORK_STATUSNET)
                $contact["network"] = NETWORK_OSTATUS;
 
+       // Replace alternate OStatus user format with the primary one
+       fix_alternate_contact_address($contact);
+
        if (!isset($contact["updated"]))
                $contact["updated"] = datetime_convert();
 
@@ -1571,7 +1588,7 @@ function update_gcontact($contact) {
 function update_gcontact_from_probe($url) {
        $data = probe_url($url);
 
-       if ($data["network"] == NETWORK_PHANTOM)
+       if (in_array($data["network"], array(NETWORK_FEED, NETWORK_PHANTOM)))
                return;
 
        update_gcontact($data);
index ffb486a7dbb194358ccb85dd95f763fba9d524e9..60e6931583426f08bc91f2827972fbecd40be94d 100644 (file)
@@ -1147,7 +1147,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
 
                        if (!$r) {
                                $probed = probe_url($name);
-                               if (isset($probed["url"])) {
+                               if ($result['network'] != NETWORK_PHANTOM) {
                                        update_gcontact($probed);
                                        $r = q("SELECT `url`, `name`, `nick`, `network`, `alias`, `notify` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
                                                dbesc(normalise_link($probed["url"])));