From: Michael Vogel Date: Thu, 28 May 2015 05:51:12 +0000 (+0200) Subject: OStatus completion: The id and the plink for fetched items should now have reliable... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=24962f300229ffd54f88e3ec7ce58573603ed573;p=friendica.git OStatus completion: The id and the plink for fetched items should now have reliable values. --- diff --git a/include/ostatus_conversation.php b/include/ostatus_conversation.php index f21f8248f8..a03330a820 100644 --- a/include/ostatus_conversation.php +++ b/include/ostatus_conversation.php @@ -1,4 +1,6 @@ id) AND isset($single_conv->object->id)) + if (isset($single_conv->object->id)) $single_conv->id = $single_conv->object->id; - elseif (!isset($single_conv->id) AND isset($single_conv->object->url)) - $single_conv->id = $single_conv->object->url; + + logger("Got id ".$single_conv->id, LOGGER_DEBUG); + + //if (!isset($single_conv->id) AND isset($single_conv->object->id)) + // $single_conv->id = $single_conv->object->id; + //elseif (!isset($single_conv->id) AND isset($single_conv->object->url)) + // $single_conv->id = $single_conv->object->url; $plink = ostatus_convert_href($single_conv->id); + if (isset($single_conv->object->url)) + $plink = ostatus_convert_href($single_conv->object->url); + + logger("Got url ".$plink, LOGGER_DEBUG); - if (isset($single_conv->provider->url) AND isset($single_conv->statusnet_notice_info->local_id)) - $plink = $single_conv->provider->url."notice/".$single_conv->statusnet_notice_info->local_id; - elseif (isset($single_conv->provider->url) AND isset($single_conv->statusnet->notice_info->local_id)) - $plink = $single_conv->provider->url."notice/".$single_conv->statusnet->notice_info->local_id; - elseif (isset($single_conv->provider->url) AND isset($single_conv->status_net->notice_info->local_id)) - $plink = $single_conv->provider->url."notice/".$single_conv->status_net->notice_info->local_id; + //if (isset($single_conv->provider->url) AND isset($single_conv->statusnet_notice_info->local_id)) + // $plink = $single_conv->provider->url."notice/".$single_conv->statusnet_notice_info->local_id; + //elseif (isset($single_conv->provider->url) AND isset($single_conv->statusnet->notice_info->local_id)) + // $plink = $single_conv->provider->url."notice/".$single_conv->statusnet->notice_info->local_id; + //elseif (isset($single_conv->provider->url) AND isset($single_conv->status_net->notice_info->local_id)) + // $plink = $single_conv->provider->url."notice/".$single_conv->status_net->notice_info->local_id; if (@!$single_conv->id) continue; @@ -197,14 +208,25 @@ function complete_conversation($itemid, $conversation_url, $only_add_conversatio continue; } + $actor = $single_conv->actor->id; + if (isset($single_conv->actor->url)) + $actor = $single_conv->actor->url; + $contact = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` != '%s'", - $message["uid"], normalise_link($single_conv->actor->id), NETWORK_STATUSNET); + $message["uid"], normalise_link($actor), NETWORK_STATUSNET); if (count($contact)) { - logger("Found contact for url ".$single_conv->actor->id, LOGGER_DEBUG); + logger("Found contact for url ".$actor, LOGGER_DEBUG); $contact_id = $contact[0]["id"]; } else { - logger("No contact found for url ".$single_conv->actor->id, LOGGER_DEBUG); + logger("No contact found for url ".$actor, LOGGER_DEBUG); + + // Adding a global contact + // To-Do: Use this data for the post + $global_contact_id = get_contact($actor, 0); + + logger("Global contact ".$global_contact_id." found for url ".$actor, LOGGER_DEBUG); + $contact_id = $parent["contact-id"]; } @@ -227,12 +249,12 @@ function complete_conversation($itemid, $conversation_url, $only_add_conversatio if ($arr["owner-name"] == '') $arr["owner-name"] = $single_conv->actor->displayName; - $arr["owner-link"] = $single_conv->actor->id; + $arr["owner-link"] = $actor; $arr["owner-avatar"] = $single_conv->actor->image->url; //$arr["author-name"] = $single_conv->actor->contact->displayName; //$arr["author-name"] = $single_conv->actor->contact->preferredUsername; $arr["author-name"] = $arr["owner-name"]; - $arr["author-link"] = $single_conv->actor->id; + $arr["author-link"] = $actor; $arr["author-avatar"] = $single_conv->actor->image->url; $arr["body"] = html2bbcode($single_conv->content);