mirror of
https://github.com/friendica/friendica
synced 2024-12-23 18:00:17 +00:00
Better updating of contacts
This commit is contained in:
parent
0fa84d01b0
commit
0083c16e87
2 changed files with 54 additions and 28 deletions
|
@ -2201,21 +2201,9 @@ function update_gcontact($contact) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($contact["server_url"] == "") {
|
if ($contact["server_url"] == "") {
|
||||||
$server_url = $contact["url"];
|
$data = Probe::uri($contact["url"]);
|
||||||
|
if ($data["network"] != NETWORK_PHANTOM) {
|
||||||
$server_url = matching_url($server_url, $contact["alias"]);
|
$contact["server_url"] = $data['baseurl'];
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$contact["server_url"] = normalise_link($contact["server_url"]);
|
$contact["server_url"] = normalise_link($contact["server_url"]);
|
||||||
|
|
|
@ -12,6 +12,7 @@ use Friendica\App;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
|
use dba;
|
||||||
use dbm;
|
use dbm;
|
||||||
use Cache;
|
use Cache;
|
||||||
use xml;
|
use xml;
|
||||||
|
@ -381,19 +382,52 @@ class Probe {
|
||||||
&& $data["addr"]
|
&& $data["addr"]
|
||||||
&& $data["poll"]
|
&& $data["poll"]
|
||||||
) {
|
) {
|
||||||
q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `url` = '%s', `addr` = '%s',
|
$fields = array('name' => $data['name'],
|
||||||
`notify` = '%s', `poll` = '%s', `alias` = '%s', `success_update` = '%s'
|
'nick' => $data['nick'],
|
||||||
WHERE `nurl` = '%s' AND NOT `self` AND `uid` = 0",
|
'url' => $data['url'],
|
||||||
dbesc($data["name"]),
|
'addr' => $data['addr'],
|
||||||
dbesc($data["nick"]),
|
'photo' => $data['photo'],
|
||||||
dbesc($data["url"]),
|
'keywords' => $data['keywords'],
|
||||||
dbesc($data["addr"]),
|
'location' => $data['location'],
|
||||||
dbesc($data["notify"]),
|
'about' => $data['about'],
|
||||||
dbesc($data["poll"]),
|
'notify' => $data['notify'],
|
||||||
dbesc($data["alias"]),
|
'network' => $data['network'],
|
||||||
dbesc(datetime_convert()),
|
'server_url' => $data['baseurl'],
|
||||||
dbesc(normalise_link($data['url']))
|
'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'];
|
$data = $ret['body'];
|
||||||
|
|
||||||
|
// This is a bugfix for this issue: https://github.com/redmatrix/hubzilla/issues/851
|
||||||
|
// $data = str_replace('&url=', '&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);
|
$xrd = parse_xml_string($data, false);
|
||||||
|
|
||||||
if (!is_object($xrd)) {
|
if (!is_object($xrd)) {
|
||||||
|
|
Loading…
Reference in a new issue