X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fdfrn.php;h=5977ed9a0c254c044516c70035bb1acf1b0a963a;hb=7177cc38581e2e4d83e4f5d5fac4a70e3c38410f;hp=7221d52a203d981c683dc0de3947510a7fdc75f3;hpb=0811f9257ef3ee032c9ad307c96a626c76239e2a;p=friendica.git diff --git a/include/dfrn.php b/include/dfrn.php index 7221d52a20..5977ed9a0c 100644 --- a/include/dfrn.php +++ b/include/dfrn.php @@ -817,6 +817,28 @@ class dfrn { xml::add_element($doc, $entry, "thr:in-reply-to", "", $attributes); } + // Add conversation data. This is used for OStatus + $conversation_href = App::get_baseurl()."/display/".$owner["nick"]."/".$item["parent"]; + $conversation_uri = $conversation_href; + + if (isset($parent_item)) { + $r = dba::fetch_first("SELECT `conversation-uri`, `conversation-href` FROM `conversation` WHERE `item-uri` = ?", $item['parent-uri']); + if (dbm::is_result($r)) { + if ($r['conversation-uri'] != '') { + $conversation_uri = $r['conversation-uri']; + } + if ($r['conversation-href'] != '') { + $conversation_href = $r['conversation-href']; + } + } + } + + $attributes = array( + "href" => $conversation_href, + "ref" => $conversation_uri); + + xml::add_element($doc, $entry, "ostatus:conversation", $conversation_uri, $attributes); + xml::add_element($doc, $entry, "id", $item["uri"]); xml::add_element($doc, $entry, "title", $item["title"]); @@ -868,7 +890,7 @@ class dfrn { // The signed text contains the content in Markdown, the sender handle and the signatur for the content // It is needed for relayed comments to Diaspora. - if($item['signed_text']) { + if ($item['signed_text']) { $sign = base64_encode(json_encode(array('signed_text' => $item['signed_text'],'signature' => $item['signature'],'signer' => $item['signer']))); xml::add_element($doc, $entry, "dfrn:diaspora_signature", $sign); } @@ -1288,7 +1310,7 @@ class dfrn { $href = ""; $width = 0; foreach ($avatar->attributes AS $attributes) { - /// @TODO Rewrite these similar if() to one switch + /// @TODO Rewrite these similar if () to one switch if ($attributes->name == "href") { $href = $attributes->textContent; } @@ -1460,7 +1482,7 @@ class dfrn { dbesc($contact["name"]), dbesc($contact["nick"]), dbesc($contact["about"]), dbesc($contact["location"]), dbesc($contact["addr"]), dbesc($contact["keywords"]), dbesc($contact["bdyear"]), dbesc($contact["bd"]), intval($contact["hidden"]), dbesc($contact["xmpp"]), - dbesc($contact["name-date"]), dbesc($contact["uri-date"]), + dbesc(dbm::date($contact["name-date"])), dbesc(dbm::date($contact["uri-date"])), intval($contact["id"]), dbesc($contact["network"])); } @@ -2165,7 +2187,7 @@ class dfrn { $title = ""; foreach ($links AS $link) { foreach ($link->attributes AS $attributes) { - /// @TODO Rewrite these repeated (same) if() statements to a switch() + /// @TODO Rewrite these repeated (same) if () statements to a switch() if ($attributes->name == "href") { $href = $attributes->textContent; } @@ -2209,12 +2231,16 @@ class dfrn { * @param array $importer Record of the importer user mixed with contact of the content * @todo Add type-hints */ - private static function process_entry($header, $xpath, $entry, $importer) { + private static function process_entry($header, $xpath, $entry, $importer, $xml) { logger("Processing entries"); $item = $header; + $item["protocol"] = PROTOCOL_DFRN; + + $item["source"] = $xml; + // Get the uri $item["uri"] = $xpath->query("atom:id/text()", $entry)->item(0)->nodeValue; @@ -2373,6 +2399,20 @@ class dfrn { self::parse_links($links, $item); } + $item['conversation-uri'] = $xpath->query('ostatus:conversation/text()', $entry)->item(0)->nodeValue; + + $conv = $xpath->query('ostatus:conversation', $entry); + if (is_object($conv->item(0))) { + foreach ($conv->item(0)->attributes AS $attributes) { + if ($attributes->name == "ref") { + $item['conversation-uri'] = $attributes->textContent; + } + if ($attributes->name == "href") { + $item['conversation-href'] = $attributes->textContent; + } + } + } + // Is it a reply or a top level posting? $item["parent-uri"] = $item["uri"]; @@ -2415,7 +2455,7 @@ class dfrn { // When activated, forums don't work. // And: Why should we disallow commenting by followers? // the behaviour is now similar to the Diaspora part. - //if($importer["rel"] == CONTACT_IS_FOLLOWER) { + //if ($importer["rel"] == CONTACT_IS_FOLLOWER) { // logger("Contact ".$importer["id"]." is only follower. Quitting", LOGGER_DEBUG); // return; //} @@ -2540,7 +2580,7 @@ class dfrn { logger("Item was stored with id ".$posted_id, LOGGER_DEBUG); - if(stristr($item["verb"],ACTIVITY_POKE)) + if (stristr($item["verb"],ACTIVITY_POKE)) self::do_poke($item, $importer, $posted_id); } } @@ -2667,7 +2707,7 @@ class dfrn { create_tags_from_itemuri($uri, $importer["uid"]); create_files_from_itemuri($uri, $importer["uid"]); update_thread_uri($uri, $importer["importer_uid"]); - if($item["last-child"]) { + if ($item["last-child"]) { // ensure that last-child is set in case the comment that had it just got wiped. q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ", dbesc(datetime_convert()), @@ -2801,7 +2841,7 @@ class dfrn { if (!$sort_by_date) { $entries = $xpath->query("/atom:feed/atom:entry"); foreach ($entries AS $entry) { - self::process_entry($header, $xpath, $entry, $importer); + self::process_entry($header, $xpath, $entry, $importer, $xml); } } else { $newentries = array(); @@ -2815,7 +2855,7 @@ class dfrn { ksort($newentries); foreach ($newentries AS $entry) { - self::process_entry($header, $xpath, $entry, $importer); + self::process_entry($header, $xpath, $entry, $importer, $xml); } } logger("Import done for user " . $importer["uid"] . " from contact " . $importer["id"], LOGGER_DEBUG);