]> git.mxchange.org Git - friendica.git/blobdiff - include/diaspora.php
Merge branch 'pull'
[friendica.git] / include / diaspora.php
index bb4bd98c744280e8efce54981d618bc492439d3f..10b342289719789bb13ed1aa643b88ca81151e55 100644 (file)
@@ -3,6 +3,7 @@
 require_once('include/crypto.php');
 require_once('include/items.php');
 require_once('include/bb2diaspora.php');
+require_once('include/contact_selectors.php');
 
 function diaspora_dispatch($importer,$msg) {
 
@@ -453,6 +454,7 @@ function diaspora_post($importer,$xml) {
        $datarray['author-link'] = $contact['url'];
        $datarray['author-avatar'] = $contact['thumb'];
        $datarray['body'] = $body;
+       $datarray['app']  = 'Diaspora';
 
        item_store($datarray);
 
@@ -483,6 +485,15 @@ function diaspora_comment($importer,$xml,$msg) {
                // NOTREACHED
        }
 
+       $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
+               intval($importer['uid']),
+               dbesc($guid)
+       );
+       if(count($r)) {
+               logger('daspora_comment: our comment just got relayed back to us (or there was a guid collision) : ' . $guid);
+               return;
+       }
+
        $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
                intval($importer['uid']),
                dbesc($parent_guid)
@@ -558,6 +569,7 @@ function diaspora_comment($importer,$xml,$msg) {
        $datarray['author-link'] = $person['url'];
        $datarray['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']);
        $datarray['body'] = $body;
+       $datarray['app']  = 'Diaspora';
 
        $message_id = item_store($datarray);
 
@@ -776,6 +788,8 @@ EOT;
        $plink = '[url=' . $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $parent_item['id'] . ']' . $post_type . '[/url]';
        $arr['body'] =  sprintf( $bodyverb, $ulink, $alink, $plink );
 
+       $arr['app']  = 'Diaspora';
+
        $arr['private'] = $parent_item['private'];
        $arr['verb'] = $activity;
        $arr['object-type'] = $objtype;
@@ -897,7 +911,8 @@ function diaspora_send_status($item,$owner,$contact) {
                }
        }       
 
-       $body = xmlify(bb2diaspora($body));
+       $body = xmlify(html_entity_decode(bb2diaspora($body)));
+
        $public = (($item['private']) ? 'false' : 'true');
 
        require_once('include/datetime.php');
@@ -990,7 +1005,7 @@ function diaspora_send_followup($item,$owner,$contact) {
                $like = false;
        }
 
-       $text = bb2diaspora($item['body']);
+       $text = html_entity_decode(bb2diaspora($item['body']));
 
        // sign it
 
@@ -1046,10 +1061,24 @@ function diaspora_send_relay($item,$owner,$contact) {
                $like = false;
        }
 
-       $text = bb2diaspora($item['body']);
+       $body = $item['body'];
+
+       $itemcontact = q("select * from contact where `id` = %d limit 1",
+               intval($item['contact-id'])
+       );
+       if(count($itemcontact)) {
+               if(! $itemcontact[0]['self']) {
+                       $prefix = sprintf( t('[Relayed] Comment authored by %s from network %s'),
+                               '['. $item['author-name'] . ']' . '(' . $item['author-link'] . ')',  
+                               network_to_name($itemcontact['network'])) . "\n";
+                       $body = $prefix . $body;
+               }
+       }
+
+       $text = html_entity_decode(bb2diaspora($body));
 
        // fetch the original signature if somebody sent the post to us to relay
-       // if we are relaying for a reply originating here, there wasn't a 'send to relay'
+       // If we are relaying for a reply originating here, there wasn't a 'send to relay'
        // action. It wasn't needed. In that case create the original signature and the 
        // owner (parent author) signature
 
@@ -1062,6 +1091,10 @@ function diaspora_send_relay($item,$owner,$contact) {
                $authorsig = $orig_sign['signature'];
        }
        else {
+
+
+
+
                if($like)
                        $signed_text = $item['guid'] . ';' . $target_type . ';' . $parent_guid . ';' . $positive . ';' . $myaddr;
                else