]> git.mxchange.org Git - friendica.git/commitdiff
Better updating of contacts
authorMichael <heluecht@pirati.ca>
Wed, 30 Aug 2017 18:05:41 +0000 (18:05 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 30 Aug 2017 18:05:41 +0000 (18:05 +0000)
include/socgraph.php
src/Network/Probe.php

index d944fa064c944c4bce4be80de3c08fd40a1aefbf..ac7f01bc34af1ec5809ed0022873e501dbf86290 100644 (file)
@@ -2201,21 +2201,9 @@ function update_gcontact($contact) {
        }
 
        if ($contact["server_url"] == "") {
-               $server_url = $contact["url"];
-
-               $server_url = matching_url($server_url, $contact["alias"]);
-               if ($server_url != "") {
-                       $contact["server_url"] = $server_url;
-               }
-
-               $server_url = matching_url($server_url, $contact["photo"]);
-               if ($server_url != "") {
-                       $contact["server_url"] = $server_url;
-               }
-
-               $server_url = matching_url($server_url, $contact["notify"]);
-               if ($server_url != "") {
-                       $contact["server_url"] = $server_url;
+               $data = Probe::uri($contact["url"]);
+               if ($data["network"] != NETWORK_PHANTOM) {
+                       $contact["server_url"] = $data['baseurl'];
                }
        } else {
                $contact["server_url"] = normalise_link($contact["server_url"]);
index 10aac01393052982ccbeaa1eee063765e68d34c3..af0895a8f4ff0287b4dbfe500d47aebe3f3d929a 100644 (file)
@@ -12,6 +12,7 @@ use Friendica\App;
 use Friendica\Core\System;
 use Friendica\Core\Config;
 
+use dba;
 use dbm;
 use Cache;
 use xml;
@@ -381,19 +382,52 @@ class Probe {
                                && $data["addr"]
                                && $data["poll"]
                        ) {
-                               q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `url` = '%s', `addr` = '%s',
-                                               `notify` = '%s', `poll` = '%s', `alias` = '%s', `success_update` = '%s'
-                                       WHERE `nurl` = '%s' AND NOT `self` AND `uid` = 0",
-                                       dbesc($data["name"]),
-                                       dbesc($data["nick"]),
-                                       dbesc($data["url"]),
-                                       dbesc($data["addr"]),
-                                       dbesc($data["notify"]),
-                                       dbesc($data["poll"]),
-                                       dbesc($data["alias"]),
-                                       dbesc(datetime_convert()),
-                                       dbesc(normalise_link($data['url']))
-                               );
+                               $fields = array('name' => $data['name'],
+                                               'nick' => $data['nick'],
+                                               'url' => $data['url'],
+                                               'addr' => $data['addr'],
+                                               'photo' => $data['photo'],
+                                               'keywords' => $data['keywords'],
+                                               'location' => $data['location'],
+                                               'about' => $data['about'],
+                                               'notify' => $data['notify'],
+                                               'network' => $data['network'],
+                                               'server_url' => $data['baseurl'],
+                                               'updated' => dbm::date());
+
+                               foreach ($fields AS $key => $val) {
+                                       if (empty($val)) {
+                                               unset($fields[$key]);
+                                       }
+                               }
+
+                               dba::update('gcontact', $fields, array('nurl' => normalise_link($data["url"])));
+
+                               $fields = array('name' => $data['name'],
+                                               'nick' => $data['nick'],
+                                               'url' => $data['url'],
+                                               'addr' => $data['addr'],
+                                               'alias' => $data['alias'],
+                                               'keywords' => $data['keywords'],
+                                               'location' => $data['location'],
+                                               'about' => $data['about'],
+                                               'batch' => $data['batch'],
+                                               'notify' => $data['notify'],
+                                               'poll' => $data['poll'],
+                                               'request' => $data['request'],
+                                               'confirm' => $data['confirm'],
+                                               'poco' => $data['poco'],
+                                               'network' => $data['network'],
+                                               'success_update' => dbm::date());
+
+                               foreach ($fields AS $key => $val) {
+                                       if (empty($val)) {
+                                               unset($fields[$key]);
+                                       }
+                               }
+
+                               $condition = array('nurl' => normalise_link($data["url"]), 'self' => false, 'uid' => 0);
+                               dba::update('contact', $fields, $condition);
                        }
                }
 
@@ -648,6 +682,10 @@ class Probe {
                }
                $data = $ret['body'];
 
+               // This is a bugfix for this issue: https://github.com/redmatrix/hubzilla/issues/851
+               // $data = str_replace('&url=', '&amp;url=', $data);
+               // we have to decide if we want to create a workaround - or we wait for an update
+
                $xrd = parse_xml_string($data, false);
 
                if (!is_object($xrd)) {