From: Michael Date: Fri, 5 May 2017 19:41:41 +0000 (+0000) Subject: Issue 3318: Make sure that we fetch an author X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=30476623c51a1161fc8a633c67ecfffefcf298a7;p=friendica.git Issue 3318: Make sure that we fetch an author --- diff --git a/include/ostatus.php b/include/ostatus.php index 40bcdcdcc5..5bd1865bd0 100644 --- a/include/ostatus.php +++ b/include/ostatus.php @@ -3,6 +3,8 @@ * @file include/ostatus.php */ +use \Friendica\Core\Config; + require_once("include/Contact.php"); require_once("include/threads.php"); require_once("include/html2bbcode.php"); @@ -79,23 +81,43 @@ class ostatus { $author = array(); $author["author-link"] = $xpath->evaluate('atom:author/atom:uri/text()', $context)->item(0)->nodeValue; $author["author-name"] = $xpath->evaluate('atom:author/atom:name/text()', $context)->item(0)->nodeValue; + $addr = $xpath->evaluate('atom:author/atom:email/text()', $context)->item(0)->nodeValue; $aliaslink = $author["author-link"]; $alternate = $xpath->query("atom:author/atom:link[@rel='alternate']", $context)->item(0)->attributes; - if (is_object($alternate)) - foreach($alternate AS $attributes) - if ($attributes->name == "href") + if (is_object($alternate)) { + foreach ($alternate AS $attributes) { + if (($attributes->name == "href") AND ($attributes->textContent != "")) { $author["author-link"] = $attributes->textContent; + } + } + } - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` IN ('%s', '%s') AND `network` != '%s'", - intval($importer["uid"]), dbesc(normalise_link($author["author-link"])), - dbesc(normalise_link($aliaslink)), dbesc(NETWORK_STATUSNET)); - if ($r) { - $contact = $r[0]; - $author["contact-id"] = $r[0]["id"]; - } else - $author["contact-id"] = $contact["id"]; + $author["contact-id"] = $contact["id"]; + + if ($author["author-link"] != "") { + if ($aliaslink == "") { + $aliaslink = $author["author-link"]; + } + + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` IN ('%s', '%s') AND `network` != '%s'", + intval($importer["uid"]), dbesc(normalise_link($author["author-link"])), + dbesc(normalise_link($aliaslink)), dbesc(NETWORK_STATUSNET)); + if (dbm::is_result($r)) { + $contact = $r[0]; + $author["contact-id"] = $r[0]["id"]; + $author["author-link"] = $r[0]["url"]; + } + } elseif ($addr != "") { + // Should not happen + $contact = dba::fetch_first("SELECT * FROM `contact` WHERE `uid` = ? AND `addr` = ? AND `network` != ?", + $importer["uid"], $addr, NETWORK_STATUSNET); + if (dbm::is_result($contact)) { + $author["contact-id"] = $contact["id"]; + $author["author-link"] = $contact["url"]; + } + } $avatarlist = array(); $avatars = $xpath->query("atom:author/atom:link[@rel='avatar']", $context); @@ -2268,6 +2290,9 @@ class ostatus { $root = self::add_header($doc, $owner); foreach ($items AS $item) { + if (Config::get('system', 'ostatus_debug')) { + $item['body'] .= '🍼'; + } $entry = self::entry($doc, $item, $owner); $root->appendChild($entry); } @@ -2288,6 +2313,10 @@ class ostatus { $doc = new DOMDocument('1.0', 'utf-8'); $doc->formatOutput = true; + if (Config::get('system', 'ostatus_debug')) { + $item['body'] .= '🐟'; + } + $entry = self::entry($doc, $item, $owner, true); $doc->appendChild($entry); diff --git a/include/pubsubpublish.php b/include/pubsubpublish.php index 3641bbcf74..1e47c3085b 100644 --- a/include/pubsubpublish.php +++ b/include/pubsubpublish.php @@ -33,6 +33,9 @@ function handle_pubsubhubbub($id) { else $rr = $r[0]; + /// @todo Check server status with poco_check_server() + // Before this can be done we need a way to safely detect the server url. + logger("Generate feed of user ".$rr['nickname']." to ".$rr['callback_url']." - last updated ".$rr['last_update'], LOGGER_DEBUG); $params = ostatus::feed($a, $rr['nickname'], $rr['last_update']);