- $arr["parent-uri"] = $parent["uri"];
- $arr["thr-parent"] = $parent_uri;
- $arr["created"] = $single_conv->published;
- $arr["edited"] = $single_conv->published;
- $arr["owner-name"] = $single_conv->actor->contact->displayName;
- //$arr["owner-name"] = $single_conv->actor->contact->preferredUsername;
- $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-link"] = $single_conv->actor->id;
- $arr["author-avatar"] = $single_conv->actor->image->url;
- $arr["body"] = html2bbcode($single_conv->content);
- $arr["app"] = strip_tags($single_conv->statusnet_notice_info->source);
- if ($arr["app"] == "")
- $arr["app"] = $single_conv->provider->displayName;
- $arr["verb"] = $parent["verb"];
- $arr["visible"] = $parent["visible"];
- $arr["location"] = $single_conv->location->displayName;
- $arr["coord"] = trim($single_conv->location->lat." ".$single_conv->location->lon);
-
- if ($arr["location"] == "")
- unset($arr["location"]);
-
- if ($arr["coord"] == "")
- unset($arr["coord"]);
-
- item_store($arr);
- //print_r($arr);
+ $arr["parent-uri"] = $parent["uri"];
+ $arr["thr-parent"] = $parent_uri;
+ $arr["created"] = $single_conv->published;
+ $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"] = $arr["owner-name"];
+ $arr["author-link"] = $single_conv->actor->id;
+ $arr["author-avatar"] = $single_conv->actor->image->url;
+ $arr["body"] = html2bbcode($single_conv->content);
+ $arr["app"] = strip_tags($single_conv->statusnet_notice_info->source);
+ if ($arr["app"] == "")
+ $arr["app"] = $single_conv->provider->displayName;
+ $arr["verb"] = $parent["verb"];
+ $arr["visible"] = $parent["visible"];
+ $arr["location"] = $single_conv->location->displayName;
+ $arr["coord"] = trim($single_conv->location->lat." ".$single_conv->location->lon);
+
+ if ($arr["location"] == "")
+ unset($arr["location"]);
+
+ if ($arr["coord"] == "")
+ unset($arr["coord"]);
+
+ $newitem = item_store($arr);
+
+ // Add the conversation entry (but don't fetch the whole conversation)
+ complete_conversation($newitem, $conversation_url, true);
+
+ // If the newly created item is the top item then change the parent settings of the thread
+ if ($newitem AND ($arr["uri"] == $first_id)) {
+ logger('setting new parent to id '.$newitem);
+ $new_parents = q("SELECT `id`, `uri`, `contact-id`, `type`, `verb`, `visible` FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1",
+ intval($message["uid"]), intval($newitem));
+ if ($new_parents) {
+ $parent = $new_parents[0];
+ logger('done changing parents to parent '.$newitem);
+ }