3 require_once('include/crypto.php');
4 require_once('include/items.php');
6 function get_diaspora_key($uri) {
9 logger('Fetching diaspora key for: ' . $uri);
15 if($a['@attributes']['rel'] === 'diaspora-public-key') {
16 $key = base64_decode($a['@attributes']['href']);
25 return rsatopem($key);
30 function diaspora_base_message($type,$data) {
32 $tpl = get_markup_template('diaspora_' . $type . '.tpl');
35 return replace_macros($tpl,$data);
40 function diaspora_msg_build($msg,$user,$contact,$prvkey,$pubkey) {
43 $inner_aes_key = random_string(32);
44 $b_inner_aes_key = base64_encode($inner_aes_key);
45 $inner_iv = random_string(32);
46 $b_inner_iv = base64_encode($inner_iv);
48 $outer_aes_key = random_string(32);
49 $b_outer_aes_key = base64_encode($outer_aes_key);
50 $outer_iv = random_string(32);
51 $b_outer_iv = base64_encode($outer_iv);
53 $handle = 'acct:' . $user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
55 $padded_data = pkcs5_pad($msg,16);
56 $inner_encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $inner_aes_key, $padded_data, MCRYPT_MODE_CBC, $inner_iv);
58 $b64_data = base64_encode($inner_encrypted);
61 $b64url_data = base64url_encode($b64_data);
62 $b64url_stripped = str_replace(array("\n","\r"," ","\t"),array('','','',''),$b64url_data);
63 $lines = str_split($b64url_stripped,60);
64 $data = implode("\n",$lines);
65 $data = $data . (($data[-1] != "\n") ? "\n" : '') ;
66 $type = 'application/atom+xml';
67 $encoding = 'base64url';
70 $signable_data = $data . '.' . base64url_encode($type) . "\n" . '.'
71 . base64url_encode($encoding) . "\n" . '.' . base64url_encode($alg) . "\n";
73 $signature = rsa_sign($signable_data,$prvkey);
74 $sig = base64url_encode($signature);
76 $decrypted_header = <<< EOT
79 <aes_key>$b_inner_aes_key</aes_key>
81 <name>{$user['username']}</name>
87 $decrypted_header = pkcs5_pad($decrypted_header,16);
89 $ciphertext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $outer_aes_key, $decrypted_header, MCRYPT_MODE_CBC, $outer_iv);
91 $outer_json = json_encode(array('iv' => $b_outer_iv,'key' => $b_outer_aes_key));
92 $encrypted_outer_key_bundle = '';
93 openssl_public_encrypt($outer_json,$encrypted_outer_key_bundle,$pubkey);
95 $b64_encrypted_outer_key_bundle = base64_encode($encrypted_outer_key_bundle);
96 $encrypted_header_json_object = json_encode(array('aes_key' => base64_encode($encrypted_outer_key_bundle),
97 'ciphertext' => base64_encode($ciphertext)));
98 $encrypted_header = '<encrypted_header>' . base64_encode($encrypted_header_json_object) . '</encrypted_header>';
101 <?xml version='1.0' encoding='UTF-8'?>
102 <entry xmlns='http://www.w3.org/2005/Atom'>
104 <me:env xmlns:me="http://salmon-protocol.org/ns/magic-env">
105 <me:encoding>base64url</me:encoding>
106 <me:alg>RSA-SHA256</me:alg>
107 <me:data type="application/atom+xml">$data</me:data>
108 <me:sig>$sig</me:sig>
119 * diaspora_decode($importer,$xml)
120 * array $importer -> from user table
121 * string $xml -> urldecoded Diaspora salmon
124 * 'message' -> decoded Diaspora XML message
125 * 'author' -> author diaspora handle
126 * 'key' -> author public key (converted to pkcs#8)
128 * Author and key are used elsewhere to save a lookup for verifying replies and likes
132 function diaspora_decode($importer,$xml) {
134 $basedom = parse_xml_string($xml);
136 $atom = $basedom->children(NAMESPACE_ATOM1);
138 // Diaspora devs: This is kind of sucky - 'encrypted_header' does not belong in the atom namespace
140 $encrypted_header = json_decode(base64_decode($atom->encrypted_header));
142 $encrypted_aes_key_bundle = base64_decode($encrypted_header->aes_key);
143 $ciphertext = base64_decode($encrypted_header->ciphertext);
145 $outer_key_bundle = '';
146 openssl_private_decrypt($encrypted_aes_key_bundle,$outer_key_bundle,$importer['prvkey']);
148 $j_outer_key_bundle = json_decode($outer_key_bundle);
150 $outer_iv = base64_decode($j_outer_key_bundle->iv);
151 $outer_key = base64_decode($j_outer_key_bundle->key);
153 $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $outer_key, $ciphertext, MCRYPT_MODE_CBC, $outer_iv);
155 $decrypted = pkcs5_unpad($decrypted);
158 * $decrypted now contains something like
161 * <iv>8e+G2+ET8l5BPuW0sVTnQw==</iv>
162 * <aes_key>UvSMb4puPeB14STkcDWq+4QE302Edu15oaprAQSkLKU=</aes_key>
164 * <name>Ryan Hughes</name>
165 * <uri>acct:galaxor@diaspora.pirateship.org</uri>
167 * </decrypted_header>
170 logger('decrypted: ' . $decrypted);
171 $idom = parse_xml_string($decrypted,false);
173 $inner_iv = base64_decode($idom->iv);
174 $inner_aes_key = base64_decode($idom->aes_key);
176 $author_link = str_replace('acct:','',$idom->author->uri);
178 $dom = $basedom->children(NAMESPACE_SALMON_ME);
180 // figure out where in the DOM tree our data is hiding
182 if($dom->provenance->data)
183 $base = $dom->provenance;
184 elseif($dom->env->data)
190 logger('mod-diaspora: unable to locate salmon data in xml ');
191 http_status_exit(400);
195 // Stash the signature away for now. We have to find their key or it won't be good for anything.
196 $signature = base64url_decode($base->sig);
200 // strip whitespace so our data element will return to one big base64 blob
201 $data = str_replace(array(" ","\t","\r","\n"),array("","","",""),$base->data);
203 // Add back the 60 char linefeeds
205 // Diaspora devs: This completely violates the entire principle of salmon magic signatures,
206 // which was to have a message signing format that was completely ambivalent to linefeeds
207 // and transport whitespace mangling, and base64 wrapping rules. Guess what? PHP and Ruby
208 // use different linelengths for base64 output.
210 $lines = str_split($data,60);
211 $data = implode("\n",$lines);
214 // stash away some other stuff for later
216 $type = $base->data[0]->attributes()->type[0];
217 $keyhash = $base->sig[0]->attributes()->keyhash[0];
218 $encoding = $base->encoding;
221 // Diaspora devs: I can't even begin to tell you how sucky this is. Read the freaking spec.
223 $signed_data = $data . (($data[-1] != "\n") ? "\n" : '') . '.' . base64url_encode($type) . "\n" . '.' . base64url_encode($encoding) . "\n" . '.' . base64url_encode($alg) . "\n";
227 $data = base64url_decode($data);
229 // Now pull out the inner encrypted blob
231 $inner_encrypted = base64_decode($data);
234 $inner_decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $inner_aes_key, $inner_encrypted, MCRYPT_MODE_CBC, $inner_iv);
236 $inner_decrypted = pkcs5_unpad($inner_decrypted);
239 logger('mod-diaspora: Could not retrieve author URI.');
240 http_status_exit(400);
243 // Once we have the author URI, go to the web and try to find their public key
244 // *** or look it up locally ***
246 logger('mod-diaspora: Fetching key for ' . $author_link );
248 // Get diaspora public key (pkcs#1) and convert to pkcs#8
250 $key = get_diaspora_key($author_link);
253 logger('mod-diaspora: Could not retrieve author key.');
254 http_status_exit(400);
257 $verify = rsa_verify($signed_data,$signature,$key);
260 logger('mod-diaspora: Message did not verify. Discarding.');
261 http_status_exit(400);
264 logger('mod-diaspora: Message verified.');
266 return array('message' => $inner_decrypted, 'author' => $author_link, 'key' => $key);
270 function diaspora_get_contact_by_handle($uid,$handle) {
271 $r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND `uid` = %d AND `addr` = '%s' LIMIT 1",
272 dbesc(NETWORK_DIASPORA),
281 function find_person_by_handle($handle) {
282 // we don't care about the uid, we just want to save an expensive webfinger probe
283 $r = q("select * from contact where network = '%s' and addr = '%s' LIMIT 1",
284 dbesc(NETWORK_DIASPORA),
289 $r = probe_url($handle);
290 // need to cached this, perhaps in fcontact
296 function diaspora_request($importer,$xml) {
298 $sender_handle = unxmlify($xml->sender_handle);
299 $recipient_handle = unxmlify($xml->recipient_handle);
301 if(! $sender_handle || ! $recipient_handle)
304 $contact = diaspora_get_contact_by_handle($importer['uid'],$sender_handle);
309 // perhaps we were already sharing with this person. Now they're sharing with us.
310 // That makes us friends.
312 if($contact['rel'] == CONTACT_IS_FOLLOWER) {
313 q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
314 intval(CONTACT_IS_FRIEND),
315 intval($contact['id']),
316 intval($importer['uid'])
319 // send notification?
323 require_once('include/Scrape.php');
324 $ret = probe_url($sender_handle);
326 if((! count($ret)) || ($ret['network'] != NETWORK_DIASPORA)) {
327 logger('diaspora_request: Cannot resolve diaspora handle ' . $sender_handle . ' for ' . $recipient_handle);
331 $r = q("INSERT INTO `contact` (`uid`, `network`,`addr`,`created`,`url`,`name`,`nick`,`photo`,`pubkey`,`notify`,`poll`,`blocked`,`priority`)
332 VALUES ( %d, '%s', '%s', '%s','%s','%s','%s','%s','%s','%s','%s',%d,%d) ",
333 intval($importer['uid']),
334 dbesc($ret['network']),
340 dbesc($ret['photo']),
341 dbesc($ret['pubkey']),
342 dbesc($ret['notify']),
348 // find the contact record we just created
350 $contact_record = diaspora_get_contact_by_handle($importer['uid'],$sender_handle);
352 $hash = random_string() . (string) time(); // Generate a confirm_key
354 if($contact_record) {
355 $ret = q("INSERT INTO `intro` ( `uid`, `contact-id`, `blocked`, `knowyou`, `note`, `hash`, `datetime`,`blocked`)
356 VALUES ( %d, %d, 1, %d, '%s', '%s', '%s', 0 )",
357 intval($importer['uid']),
358 intval($contact_record['id']),
360 dbesc( t('Sharing notification from Diaspora network')),
362 dbesc(datetime_convert())
369 function diaspora_post($importer,$xml) {
371 $guid = notags(unxmlify($xml->guid));
372 $diaspora_handle = notags(unxmlify($xml->diaspora_handle));
374 $contact = diaspora_get_contact_by_handle($importer['uid'],$diaspora_handle);
378 if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) {
379 logger('diaspora_post: Ignoring this author.');
380 http_status_exit(202);
384 $message_id = $diaspora_handle . ':' . $guid;
385 $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `guid` = '%s' LIMIT 1",
386 intval($importer['uid']),
393 // allocate a guid on our system - we aren't fixing any collisions.
394 // we're ignoring them
396 $g = q("select * from guid where guid = '%s' limit 1",
400 q("insert into guid ( guid ) values ( '%s' )",
405 $created = unxmlify($xml->created_at);
406 $private = ((unxmlify($xml->public) == 'false') ? 1 : 0);
408 $body = unxmlify($xml->raw_message);
410 require_once('library/HTMLPurifier.auto.php');
411 require_once('include/html2bbcode.php');
413 $maxlen = get_max_import_size();
414 if($maxlen && (strlen($body) > $maxlen))
415 $body = substr($body,0, $maxlen);
417 if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) {
419 $body = preg_replace('#<object[^>]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s',
420 '[youtube]$1[/youtube]', $body);
422 $body = preg_replace('#<iframe[^>].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?</iframe>#s',
423 '[youtube]$1[/youtube]', $body);
425 $body = oembed_html2bbcode($body);
427 $config = HTMLPurifier_Config::createDefault();
428 $config->set('Cache.DefinitionImpl', null);
429 $purifier = new HTMLPurifier($config);
430 $body = $purifier->purify($body);
432 $body = html2bbcode($body);
436 $datarray['uid'] = $importer['uid'];
437 $datarray['contact-id'] = $contact['id'];
438 $datarray['wall'] = 0;
439 $datarray['guid'] = $guid;
440 $datarray['uri'] = $datarray['parent-uri'] = $message_id;
441 $datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created);
442 $datarray['private'] = $private;
443 $datarray['parent'] = 0;
444 $datarray['owner-name'] = $contact['name'];
445 $datarray['owner-link'] = $contact['url'];
446 $datarray['owner-avatar'] = $contact['thumb'];
447 $datarray['author-name'] = $contact['name'];
448 $datarray['author-link'] = $contact['url'];
449 $datarray['author-avatar'] = $contact['thumb'];
450 $datarray['body'] = $body;
452 item_store($datarray);
458 function diaspora_comment($importer,$xml,$msg) {
460 $guid = notags(unxmlify($xml->guid));
461 $parent_guid = notags(unxmlify($xml->parent_guid));
462 $diaspora_handle = notags(unxmlify($xml->diaspora_handle));
463 $target_type = notags(unxmlify($xml->target_type));
464 $text = unxmlify($xml->text);
465 $author_signature = notags(unxmlify($xml->author_signature));
467 $parent_author_signature = (($xml->parent_author_signature) ? notags(unxmlify($xml->parent_author_signature)) : '');
471 $contact = diaspora_get_contact_by_handle($importer['uid'],$msg['author']);
475 if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) {
476 logger('diaspora_comment: Ignoring this author.');
477 http_status_exit(202);
481 $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
482 intval($importer['uid']),
486 logger('diaspora_comment: parent item not found: ' . $guid);
489 $parent_item = $r[0];
491 $author_signed_data = $guid . ';' . $parent_guid . ';' . $text . ';' . $diaspora_handle;
493 $author_signature = base64_decode($author_signature);
495 if(stricmp($diaspora_handle,$msg['author']) == 0) {
500 $person = find_person_by_handle($diaspora_handle);
502 if(is_array($person) && x($person,'pubkey'))
503 $key = $person['pubkey'];
505 logger('diaspora_comment: unable to find author details');
510 if(! rsa_verify($author_signed_data,$author_signature,$key)) {
511 logger('diaspora_comment: verification failed.');
515 if($parent_author_signature) {
516 $owner_signed_data = $guid . ';' . $parent_guid . ';' . $text . ';' . $msg['author'];
518 $parent_author_signature = base64_decode($parent_author_signature);
522 if(! rsa_verify($owner_signed_data,$parent_author_signature,$key)) {
523 logger('diaspora_comment: owner verification failed.');
528 // Phew! Everything checks out. Now create an item.
530 require_once('library/HTMLPurifier.auto.php');
531 require_once('include/html2bbcode.php');
535 $maxlen = get_max_import_size();
536 if($maxlen && (strlen($body) > $maxlen))
537 $body = substr($body,0, $maxlen);
539 if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) {
541 $body = preg_replace('#<object[^>]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s',
542 '[youtube]$1[/youtube]', $body);
544 $body = preg_replace('#<iframe[^>].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?</iframe>#s',
545 '[youtube]$1[/youtube]', $body);
547 $body = oembed_html2bbcode($body);
549 $config = HTMLPurifier_Config::createDefault();
550 $config->set('Cache.DefinitionImpl', null);
551 $purifier = new HTMLPurifier($config);
552 $body = $purifier->purify($body);
554 $body = html2bbcode($body);
557 $message_id = $diaspora_handle . ':' . $guid;
560 $datarray['uid'] = $importer['uid'];
561 $datarray['contact-id'] = $contact['id'];
562 $datarray['wall'] = $parent_item['wall'];
563 $datarray['gravity'] = GRAVITY_COMMENT;
564 $datarray['guid'] = $guid;
565 $datarray['uri'] = $message_id;
566 $datarray['parent-uri'] = $parent_item['uri'];
568 // No timestamps for comments? OK, we'll the use current time.
569 $datarray['created'] = $datarray['edited'] = datetime_convert();
570 $datarray['private'] = $parent_item['private'];
572 $datarray['owner-name'] = $contact['name'];
573 $datarray['owner-link'] = $contact['url'];
574 $datarray['owner-avatar'] = $contact['thumb'];
576 $datarray['author-name'] = $person['name'];
577 $datarray['author-link'] = $person['url'];
578 $datarray['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']);
579 $datarray['body'] = $body;
581 item_store($datarray);
587 function diaspora_like($importer,$xml,$msg) {
589 $guid = notags(unxmlify($xml->guid));
590 $parent_guid = notags(unxmlify($xml->parent_guid));
591 $diaspora_handle = notags(unxmlify($xml->diaspora_handle));
592 $target_type = notags(unxmlify($xml->target_type));
593 $positive = notags(unxmlify($xml->positive));
594 $author_signature = notags(unxmlify($xml->author_signature));
596 $parent_author_signature = (($xml->parent_author_signature) ? notags(unxmlify($xml->parent_author_signature)) : '');
598 // likes on comments not supported here and likes on photos not supported by Diaspora
600 if($target_type !== 'Post')
603 $contact = diaspora_get_contact_by_handle($importer['uid'],$msg['author']);
607 if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) {
608 logger('diaspora_like: Ignoring this author.');
609 http_status_exit(202);
613 $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
614 intval($importer['uid']),
618 logger('diaspora_like: parent item not found: ' . $guid);
622 $parent_item = $r[0];
624 $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '$s' LIMIT 1",
625 intval($importer['uid']),
629 if($positive === 'true') {
630 logger('diaspora_like: duplicate like: ' . $guid);
633 if($positive === 'false') {
634 q("UPDATE `item` SET `deleted` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1",
636 intval($importer['uid'])
639 // send notification via proc_run()
643 if($positive === 'false') {
644 logger('diaspora_like: unlike received with no corresponding like');
648 $author_signed_data = $guid . ';' . $parent_guid . ';' . $target_type . ';' . $positive . ';' . $diaspora_handle;
650 $author_signature = base64_decode($author_signature);
652 if(stricmp($diaspora_handle,$msg['author']) == 0) {
657 $person = find_person_by_handle($diaspora_handle);
658 if(is_array($person) && x($person,'pubkey'))
659 $key = $person['pubkey'];
661 logger('diaspora_comment: unable to find author details');
666 if(! rsa_verify($author_signed_data,$author_signature,$key)) {
667 logger('diaspora_like: verification failed.');
671 if($parent_author_signature) {
672 $owner_signed_data = $guid . ';' . $parent_guid . ';' . $target_type . ';' . $positive . ';' . $msg['author'];
674 $parent_author_signature = base64_decode($parent_author_signature);
678 if(! rsa_verify($owner_signed_data,$parent_author_signature,$key)) {
679 logger('diaspora_like: owner verification failed.');
684 // Phew! Everything checks out. Now create an item.
686 $uri = $diaspora_handle . ':' . $guid;
688 $activity = ACTIVITY_LIKE;
689 $post_type = (($parent_item['resource-id']) ? t('photo') : t('status'));
690 $objtype = (($parent_item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
691 $link = xmlify('<link rel="alternate" type="text/html" href="' . $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $parent_item['id'] . '" />' . "\n") ;
692 $body = $parent_item['body'];
697 <type>$objtype</type>
699 <id>{$parent_item['uri']}</id>
702 <content>$body</content>
705 $bodyverb = t('%1$s likes %2$s\'s %3$s');
710 $arr['uid'] = $importer['uid'];
711 $arr['contact-id'] = $contact['id'];
712 $arr['type'] = 'activity';
713 $arr['wall'] = $parent_item['wall'];
714 $arr['gravity'] = GRAVITY_LIKE;
715 $arr['parent'] = $parent_item['id'];
716 $arr['parent-uri'] = $parent_item['uri'];
718 $datarray['owner-name'] = $contact['name'];
719 $datarray['owner-link'] = $contact['url'];
720 $datarray['owner-avatar'] = $contact['thumb'];
722 $datarray['author-name'] = $person['name'];
723 $datarray['author-link'] = $person['url'];
724 $datarray['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']);
726 $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
727 $alink = '[url=' . $parent_item['author-link'] . ']' . $parent_item['author-name'] . '[/url]';
728 $plink = '[url=' . $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $parent_item['id'] . ']' . $post_type . '[/url]';
729 $arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink );
731 $arr['private'] = $parent_item['private'];
732 $arr['verb'] = $activity;
733 $arr['object-type'] = $objtype;
734 $arr['object'] = $obj;
737 $arr['last-child'] = 0;
739 $post_id = item_store($arr);
742 // FIXME send notification
747 function diaspora_retraction($importer,$xml) {
749 $guid = notags(unxmlify($xml->guid));
750 $diaspora_handle = notags(unxmlify($xml->diaspora_handle));
752 $contact = diaspora_get_contact_by_handle($importer['uid'],$diaspora_handle);
756 // if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) {
757 // logger('diaspora_retraction: Ignoring this author.');
758 // http_status_exit(202);
766 function diaspora_share($me,$contact) {
768 $myaddr = $me['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
769 $theiraddr = $contact['addr'];
771 $tpl = get_markup_template('diaspora_share.tpl');
772 $msg = replace_macros($tpl, array(
774 '$recipient' => $theiraddr
777 $slap = 'xml=' . urlencode(diaspora_msg_build($msg,$me,$contact,$me['prvkey'],$contact['pubkey']));
779 post_url($contact['notify'],$slap);
780 $return_code = $a->get_curl_code();
784 function diaspora_send_status($item,$owner,$contact) {
787 $myaddr = $owner['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
788 $theiraddr = $contact['addr'];
789 require_once('include/bbcode.php');
791 $body = xmlify(bbcode($item['body']));
792 $public = (($item['private']) ? 'false' : 'true');
794 require_once('include/datetime.php');
795 $created = datetime_convert('UTC','UTC',$item['created'],'Y-m-d h:i:s \U\T\C');
797 $tpl = get_markup_template('diaspora_post.tpl');
798 $msg = replace_macros($tpl, array(
800 '$guid' => $item['guid'],
801 '$handle' => xmlify($myaddr),
802 '$public' => $public,
803 '$created' => $created
806 logger('diaspora_send_status: base message: ' . $msg, LOGGER_DATA);
808 $slap = 'xml=' . urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey']));
810 post_url($contact['notify'],$slap);
811 $return_code = $a->get_curl_code();
812 logger('diaspora_send_status: returns: ' . $return_code);