Merge pull request #691 from annando/master
OStatus autocompletion improved
This commit is contained in:
commit
ae97ee9040
2 changed files with 109 additions and 94 deletions
|
@ -75,19 +75,29 @@ function complete_conversation($itemid, $conversation_url, $only_add_conversatio
|
||||||
require_once('include/items.php');
|
require_once('include/items.php');
|
||||||
|
|
||||||
$conv = str_replace("/conversation/", "/api/statusnet/conversation/", $conversation_url).".as";
|
$conv = str_replace("/conversation/", "/api/statusnet/conversation/", $conversation_url).".as";
|
||||||
|
$pageno = 1;
|
||||||
|
$items = array();
|
||||||
|
|
||||||
logger('complete_conversation: fetching conversation url '.$conv.' for '.$itemid);
|
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 = str_replace(',"statusnet:notice_info":', ',"statusnet_notice_info":', $conv_as);
|
||||||
$conv_as = json_decode($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;
|
return;
|
||||||
$items = array_reverse($conv_as->items);
|
|
||||||
|
$items = array_reverse($items);
|
||||||
|
|
||||||
foreach ($items as $single_conv) {
|
foreach ($items as $single_conv) {
|
||||||
if (@!$single_conv->id AND $single_conv->provider->url AND $single_conv->statusnet_notice_info->local_id)
|
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["edited"] = $single_conv->published;
|
||||||
//$arr["owner-name"] = $single_conv->actor->contact->displayName;
|
//$arr["owner-name"] = $single_conv->actor->contact->displayName;
|
||||||
$arr["owner-name"] = $single_conv->actor->contact->preferredUsername;
|
$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-link"] = $single_conv->actor->id;
|
||||||
$arr["owner-avatar"] = $single_conv->actor->image->url;
|
$arr["owner-avatar"] = $single_conv->actor->image->url;
|
||||||
//$arr["author-name"] = $single_conv->actor->contact->displayName;
|
//$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-link"] = $single_conv->actor->id;
|
||||||
$arr["author-avatar"] = $single_conv->actor->image->url;
|
$arr["author-avatar"] = $single_conv->actor->image->url;
|
||||||
$arr["body"] = html2bbcode($single_conv->content);
|
$arr["body"] = html2bbcode($single_conv->content);
|
||||||
|
@ -186,6 +202,5 @@ function complete_conversation($itemid, $conversation_url, $only_add_conversatio
|
||||||
logger('complete_conversation: done changing parents to parent '.$newitem.' '.print_r($r, true));*/
|
logger('complete_conversation: done changing parents to parent '.$newitem.' '.print_r($r, true));*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue