]> git.mxchange.org Git - friendica.git/commitdiff
diaspora follow from friendika
authorFriendika <info@friendika.com>
Mon, 15 Aug 2011 03:38:31 +0000 (20:38 -0700)
committerFriendika <info@friendika.com>
Mon, 15 Aug 2011 03:38:31 +0000 (20:38 -0700)
include/diaspora.php
mod/follow.php

index 3310e6d32fe001f2d9e38354904fbfd637fb4a4b..d8be2b2cc825dc3a1b88916c1207c9a3288ae820 100644 (file)
@@ -77,7 +77,7 @@ $decrypted_header = <<< EOT
   <iv>$b_inner_iv</iv>
   <aes_key>$b_inner_aes_key</aes_key>
   <author>
-    <name>{$contact['name']}</name>
+    <name>{$user['username']}</name>
     <uri>$handle</uri>
   </author>
 </decrypted_header>
@@ -170,7 +170,7 @@ function diaspora_decode($importer,$xml) {
        
        if(! $base) {
                logger('mod-diaspora: unable to locate salmon data in xml ');
-               dt_return(400);
+               http_status_exit(400);
        }
 
 
@@ -519,3 +519,24 @@ function diaspora_retraction($importer,$contact,$xml) {
 
 }
 
+function diaspora_share($me,$contact) {
+       $a = get_app();
+       $myaddr = $me['nickname'] . '@' .  substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+       $theiraddr = $contact['addr'];
+
+       $tpl = get_markup_template('diaspora_share.tpl');
+       $msg = replace_macros($tpl, array(
+               '$sender' => myaddr,
+               '$recipient' => $theiraddr
+       ));
+
+       $slap = diaspora_msg_build($msg,$me,$contact,$me['prvkey'],$contact['pubkey']);
+
+       post_url($contact['notify'],$slap, array(
+               'Content-type: application/magic-envelope+xml',
+               'Content-length: ' . strlen($slap)
+       ));
+       $return_code = $a->get_curl_code();
+       return $return_code;
+}
+
index 80226f3b9e00094d6fdacbc38db65bb45419cb9f..48bccc5aacec33e4b5dca6da32711e4b3ff63d0c 100644 (file)
@@ -71,6 +71,7 @@ function follow_post(&$a) {
                $writeable = 1;
                
        }
+
        // check if we already have a contact
        // the poll url is more reliable than the profile url, as we may have
        // indirect links or webfinger links
@@ -175,10 +176,16 @@ function follow_post(&$a) {
                        intval(local_user())
        );
 
-
-       if((count($r)) && (x($contact,'notify')) && (strlen($contact['notify']))) {
-               require_once('include/salmon.php');
-               slapper($r[0],$contact['notify'],$slap);
+       if(count($r)) {
+               if(($contact['network'] == NETWORK_OSTATUS) && (strlen($contact['notify']))) {
+                       require_once('include/salmon.php');
+                       slapper($r[0],$contact['notify'],$slap);
+               }
+               if($contact['network'] == NETWORK_DIASPORA) {
+                       require_once('include/diaspora.php');
+                       $ret = diaspora_share($a->user,$r[0]);
+                       logger('mod_follow: diaspora_share returns: ' . $ret);
+               }
        }
 
        goaway($_SESSION['return_url']);