- } else
- logger('Author '.$person['url'].' is allowed for uid '.$uid);
-
- $datarray = array();
- $datarray['uid'] = $uid;
- $datarray['contact-id'] = $contact_id;
- $datarray['wall'] = 0;
- $datarray['network'] = NETWORK_DIASPORA;
- $datarray['guid'] = $guid;
- $datarray['uri'] = $datarray['parent-uri'] = $message_id;
- $datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created);
- $datarray['private'] = $private;
- $datarray['parent'] = 0;
- $datarray['plink'] = diaspora_plink($author, $guid);
- $datarray['author-name'] = $person['name'];
- $datarray['author-link'] = $person['url'];
- $datarray['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']);
- $datarray['owner-name'] = $datarray['author-name'];
- $datarray['owner-link'] = $datarray['author-link'];
- $datarray['owner-avatar'] = $datarray['author-avatar'];
- $datarray['body'] = $body;
- $datarray['tag'] = $str_tags;
- $datarray['app'] = $app;
- $datarray['visible'] = ((strlen($body)) ? 1 : 0);
- $datarray['object'] = $object;
- $datarray['object-type'] = $objecttype;
-
- if ($datarray['contact-id'] == 0)
- return false;
-
- DiasporaFetchGuid($datarray);
- $message_id = item_store($datarray);
-
- /// @TODO
- /// Looking if there is some subscribe mechanism in Diaspora to get all comments for this post
-
- return $message_id;
-}
-
-function diaspora_fetch_message($guid, $server, $level = 0) {
-
- if ($level > 5)
- return false;
-
- $a = get_app();
-
- // This will not work if the server is not a Diaspora server
- $source_url = $server.'/p/'.$guid.'.xml';
- $x = fetch_url($source_url);
- if(!$x)
- return false;
-
- $x = str_replace(array('<activity_streams-photo>','</activity_streams-photo>'),array('<asphoto>','</asphoto>'),$x);
- $source_xml = parse_xml_string($x,false);
-
- $item = array();
- $item["app"] = 'Diaspora';
- $item["guid"] = $guid;
- $body = "";
-
- if ($source_xml->post->status_message->created_at)
- $item["created"] = unxmlify($source_xml->post->status_message->created_at);
-
- if ($source_xml->post->status_message->provider_display_name)
- $item["app"] = unxmlify($source_xml->post->status_message->provider_display_name);
-
- if ($source_xml->post->status_message->diaspora_handle)
- $item["author"] = unxmlify($source_xml->post->status_message->diaspora_handle);
-
- if ($source_xml->post->status_message->guid)
- $item["guid"] = unxmlify($source_xml->post->status_message->guid);
-
- $item["private"] = (unxmlify($source_xml->post->status_message->public) == 'false');
- $item["object"] = json_encode($source_xml->post);