From: Michael Vogel Date: Sun, 6 Mar 2016 19:36:28 +0000 (+0100) Subject: New way of fetching the conversation id for thread completion X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ef2bc47cc6d8f6be3fda65aec366ad237396a52c;p=friendica.git New way of fetching the conversation id for thread completion --- diff --git a/include/ostatus.php b/include/ostatus.php index 44431967ec..138f510906 100644 --- a/include/ostatus.php +++ b/include/ostatus.php @@ -537,7 +537,7 @@ function ostatus_import($xml,$importer,&$contact, &$hub) { } else $item["parent-uri"] = $item["uri"]; - $item_id = ostatus_completion($conversation, $importer["uid"], $item); + $item_id = ostatus_completion($conversation, $importer["uid"], $item, $self); if (!$item_id) { logger("Error storing item", LOGGER_DEBUG); @@ -676,18 +676,49 @@ function ostatus_conv_fetch_actor($actor) { update_gcontact($contact); } +function ostatus_fetch_conversation($self, $conversation_url = "") { -function ostatus_completion($conversation_url, $uid, $item = array()) { + if ($conversation_url != "") { + $elements = explode(":", $conversation_url); + + if ((count($elements) <= 2) OR ($elements[0] != "tag")) + return $conversation_url; + } + + if ($self == "") + return ""; + + $json = str_replace(".atom", ".json", $self); + + $raw = fetch_url($json); + if ($raw == "") + return ""; + + $data = json_decode($raw); + if (!is_object($data)) + return ""; + + $conversation_id = $data->statusnet_conversation_id; + + $pos = strpos($self, "/api/statuses/show/"); + $base_url = substr($self, 0, $pos); + + return $base_url."/conversation/".$conversation_id; +} + +function ostatus_completion($conversation_url, $uid, $item = array(), $self = "") { $a = get_app(); $item_stored = -1; - $conversation_url = ostatus_convert_href($conversation_url); + //$conversation_url = ostatus_convert_href($conversation_url); + $conversation_url = ostatus_fetch_conversation($self, $conversation_url); // If the thread shouldn't be completed then store the item and go away // Don't do a completion on liked content - if (((intval(get_config('system','ostatus_poll_interval')) == -2) AND (count($item) > 0)) OR ($item["verb"] == ACTIVITY_LIKE)) { + if (((intval(get_config('system','ostatus_poll_interval')) == -2) AND (count($item) > 0)) OR + ($item["verb"] == ACTIVITY_LIKE) OR ($conversation_url == "")) { //$arr["app"] .= " (OStatus-NoCompletion)"; $item_stored = item_store($item, true); return($item_stored); @@ -726,7 +757,7 @@ function ostatus_completion($conversation_url, $uid, $item = array()) { $pageno = 1; $items = array(); - logger('fetching conversation url '.$conv.' ('.$conversation_url.') for user '.$uid); + logger('fetching conversation url '.$conv.' (Self: '.$self.') for user '.$uid); do { $conv_arr = z_fetch_url($conv."?page=".$pageno);