]> git.mxchange.org Git - friendica.git/blobdiff - include/diaspora.php
Merge pull request #621 from annando/master
[friendica.git] / include / diaspora.php
index 18d37c243e212a992419f2de80a0dd09a54f096e..5bf45e241fe1013b230f041bbd7b498918f05eac 100755 (executable)
@@ -559,7 +559,7 @@ function diaspora_decode($importer,$xml) {
 
 }
 
-       
+
 function diaspora_request($importer,$xml) {
 
        $a = get_app();
@@ -569,7 +569,7 @@ function diaspora_request($importer,$xml) {
 
        if(! $sender_handle || ! $recipient_handle)
                return;
-        
+
        $contact = diaspora_get_contact_by_handle($importer['uid'],$sender_handle);
 
        if($contact) {
@@ -754,6 +754,20 @@ function diaspora_request($importer,$xml) {
 }
 
 function diaspora_post_allow($importer,$contact) {
+
+       // perhaps we were already sharing with this person. Now they're sharing with us.
+       // That makes us friends.
+       // Normally this should have handled by getting a request - but this could get lost
+       if($contact['rel'] == CONTACT_IS_FOLLOWER && $importer['page-flags'] != PAGE_COMMUNITY) {
+               q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1",
+                       intval(CONTACT_IS_FRIEND),
+                       intval($contact['id']),
+                       intval($importer['uid'])
+               );
+               $contact['rel'] = CONTACT_IS_FRIEND;
+               logger('diaspora_post_allow: defining user '.$contact["nick"].' as friend');
+       }
+
        if(($contact['blocked']) || ($contact['readonly']) || ($contact['archive']))
                return false;
        if($contact['rel'] == CONTACT_IS_SHARING || $contact['rel'] == CONTACT_IS_FRIEND)