ostatus completion of threads now works with longer threads well.

This commit is contained in:
Michael Vogel 2013-06-08 12:28:19 +02:00
parent 0723933c1c
commit a2cef94d8b
2 changed files with 109 additions and 94 deletions

View File

@ -75,19 +75,29 @@ function complete_conversation($itemid, $conversation_url, $only_add_conversatio
require_once('include/items.php');
$conv = str_replace("/conversation/", "/api/statusnet/conversation/", $conversation_url).".as";
$pageno = 1;
$items = array();
logger('complete_conversation: fetching conversation url '.$conv.' for '.$itemid);
$conv_as = fetch_url($conv);
if ($conv_as) {
do {
$conv_as = file_get_contents($conv."?page=".$pageno);
$conv_as = str_replace(',"statusnet:notice_info":', ',"statusnet_notice_info":', $conv_as);
$conv_as = json_decode($conv_as);
$first_id = "";
if (@is_array($conv_as->items))
$items = array_merge($items, $conv_as->items);
else
break;
if (!is_array($conv_as->items))
$pageno++;
} while (true);
if (!sizeof($items))
return;
$items = array_reverse($conv_as->items);
$items = array_reverse($items);
foreach ($items as $single_conv) {
if (@!$single_conv->id AND $single_conv->provider->url AND $single_conv->statusnet_notice_info->local_id)
@ -142,10 +152,16 @@ function complete_conversation($itemid, $conversation_url, $only_add_conversatio
$arr["edited"] = $single_conv->published;
//$arr["owner-name"] = $single_conv->actor->contact->displayName;
$arr["owner-name"] = $single_conv->actor->contact->preferredUsername;
if ($arr["owner-name"] == '')
$arr["owner-name"] = $single_conv->actor->portablecontacts_net->preferredUsername;
if ($arr["owner-name"] == '')
$arr["owner-name"] = $single_conv->actor->displayName;
$arr["owner-link"] = $single_conv->actor->id;
$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"] = $single_conv->actor->contact->preferredUsername;
$arr["author-name"] = $arr["owner-name"];
$arr["author-link"] = $single_conv->actor->id;
$arr["author-avatar"] = $single_conv->actor->image->url;
$arr["body"] = html2bbcode($single_conv->content);
@ -187,5 +203,4 @@ function complete_conversation($itemid, $conversation_url, $only_add_conversatio
}
}
}
}
?>