Bugfix: The nickname vanished/better way to fetch the alias

This commit is contained in:
Michael Vogel 2016-04-02 15:41:55 +02:00
parent e5377a5e91
commit b4b62493e6
4 changed files with 23 additions and 8 deletions

View File

@ -23,13 +23,15 @@ function scrape_dfrn($url, $dont_probe = false) {
if (is_array($noscrapedata)) { if (is_array($noscrapedata)) {
if ($noscrapedata["nick"] != "") if ($noscrapedata["nick"] != "")
return($noscrapedata); return($noscrapedata);
else
unset($noscrapedata["nick"]);
} else } else
$noscrapedata = array(); $noscrapedata = array();
} }
$s = fetch_url($url); $s = fetch_url($url);
if(! $s) if (!$s)
return $ret; return $ret;
if (!$dont_probe) { if (!$dont_probe) {
@ -703,6 +705,9 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
if (($vcard["nick"] == "") AND ($data["header"]["author-nick"] != "")) if (($vcard["nick"] == "") AND ($data["header"]["author-nick"] != ""))
$vcard["nick"] = $data["header"]["author-nick"]; $vcard["nick"] = $data["header"]["author-nick"];
if (($network == NETWORK_OSTATUS) AND ($data["header"]["author-id"] != ""))
$alias = $data["header"]["author-id"];
if(!$profile AND ($data["header"]["author-link"] != "") AND !in_array($network, array("", NETWORK_FEED))) if(!$profile AND ($data["header"]["author-link"] != "") AND !in_array($network, array("", NETWORK_FEED)))
$profile = $data["header"]["author-link"]; $profile = $data["header"]["author-link"];
} }
@ -844,13 +849,17 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
/// The biggest problem is the avatar picture that could have a reduced image size. /// The biggest problem is the avatar picture that could have a reduced image size.
/// It should only be updated if the existing picture isn't existing anymore. /// It should only be updated if the existing picture isn't existing anymore.
if (($result['network'] != NETWORK_FEED) AND ($mode == PROBE_NORMAL) AND if (($result['network'] != NETWORK_FEED) AND ($mode == PROBE_NORMAL) AND
$result["addr"] AND $result["name"] AND $result["nick"]) $result["name"] AND $result["nick"] AND $result["url"] AND $result["addr"] AND $result["poll"])
q("UPDATE `contact` SET `addr` = '%s', `alias` = '%s', `name` = '%s', `nick` = '%s', q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `url` = '%s', `addr` = '%s',
`success_update` = '%s' WHERE `nurl` = '%s' AND NOT `self` AND `uid` = 0", `notify` = '%s', `poll` = '%s', `alias` = '%s', `success_update` = '%s'
dbesc($result["addr"]), WHERE `nurl` = '%s' AND NOT `self` AND `uid` = 0",
dbesc($result["alias"]),
dbesc($result["name"]), dbesc($result["name"]),
dbesc($result["nick"]), dbesc($result["nick"]),
dbesc($result["url"]),
dbesc($result["addr"]),
dbesc($result["notify"]),
dbesc($result["poll"]),
dbesc($result["alias"]),
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc(normalise_link($result['url'])) dbesc(normalise_link($result['url']))
); );

View File

@ -405,6 +405,9 @@ function cron_repair_database() {
// This call is very "cheap" so we can do it at any time without a problem // This call is very "cheap" so we can do it at any time without a problem
q("UPDATE `item` INNER JOIN `item` AS `parent` ON `parent`.`uri` = `item`.`parent-uri` AND `parent`.`uid` = `item`.`uid` SET `item`.`parent` = `parent`.`id` WHERE `item`.`parent` = 0"); q("UPDATE `item` INNER JOIN `item` AS `parent` ON `parent`.`uri` = `item`.`parent-uri` AND `parent`.`uid` = `item`.`uid` SET `item`.`parent` = `parent`.`id` WHERE `item`.`parent` = 0");
// There was an issue where the nick vanishes from the contact table
q("UPDATE `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid` SET `nick` = `nickname` WHERE `self` AND `nick`=''");
/// @todo /// @todo
/// - remove thread entries without item /// - remove thread entries without item
/// - remove sign entries without item /// - remove sign entries without item

View File

@ -54,8 +54,10 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
if ($attributes->name == "href") if ($attributes->name == "href")
$author["author-link"] = $attributes->textContent; $author["author-link"] = $attributes->textContent;
$author["author-id"] = $xpath->evaluate('/atom:feed/atom:author/atom:uri/text()')->item(0)->nodeValue;
if ($author["author-link"] == "") if ($author["author-link"] == "")
$author["author-link"] = $xpath->evaluate('/atom:feed/atom:author/atom:uri/text()')->item(0)->nodeValue; $author["author-link"] = $author["author-id"];
if ($author["author-link"] == "") { if ($author["author-link"] == "") {
$self = $xpath->query("atom:link[@rel='self']")->item(0)->attributes; $self = $xpath->query("atom:link[@rel='self']")->item(0)->attributes;
@ -127,6 +129,7 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
// This is no field in the item table. So we have to unset it. // This is no field in the item table. So we have to unset it.
unset($author["author-nick"]); unset($author["author-nick"]);
unset($author["author-id"]);
} }
$header = array(); $header = array();

View File

@ -28,7 +28,7 @@ function noscrape_init(&$a) {
$json_info = array( $json_info = array(
'fn' => $a->profile['name'], 'fn' => $a->profile['name'],
'addr' => $a->profile['addr'], 'addr' => $a->profile['addr'],
'nick' => $a->user['nickname'], 'nick' => $which,
'key' => $a->profile['pubkey'], 'key' => $a->profile['pubkey'],
'homepage' => $a->get_baseurl()."/profile/{$which}", 'homepage' => $a->get_baseurl()."/profile/{$which}",
'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY), 'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),