]> git.mxchange.org Git - friendica.git/commitdiff
Diaspora: Auto-adding users as friend who already sharing with us
authorMichael - piratica.eu <ike@piratenpartei.de>
Sun, 20 Jan 2013 13:08:28 +0000 (14:08 +0100)
committerMichael - piratica.eu <ike@piratenpartei.de>
Sun, 20 Jan 2013 13:08:28 +0000 (14:08 +0100)
include/Scrape.php
include/diaspora.php
include/follow.php
include/network.php
include/poller.php
view/theme/vier/profile_vcard.tpl

index 611cbda8860e05a48eb6237523001f0da90af354..7b72a199dfe1307a689dbe4d3a3321ac015686be 100644 (file)
@@ -346,7 +346,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
        $network = null;
        $diaspora = false;
        $diaspora_base = '';
-       $diaspora_guid = '';    
+       $diaspora_guid = '';
        $diaspora_key = '';
        $has_lrdd = false;
        $email_conversant = false;
@@ -485,7 +485,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
                                }
                        }
                }
-       }       
+       }
 
        if($mode == PROBE_NORMAL) {
                if(strlen($zot)) {
@@ -531,7 +531,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
                }
                if(strpos($url,'@'))
                        $addr = str_replace('acct:', '', $url);
-       }                       
+       }
 
        if($network !== NETWORK_ZOT && $network !== NETWORK_DFRN && $network !== NETWORK_MAIL) {
                if($diaspora)
@@ -544,13 +544,13 @@ function probe_url($url, $mode = PROBE_NORMAL) {
                        $vcard = scrape_vcard($hcard);
 
                        // Google doesn't use absolute url in profile photos
-       
+
                        if((x($vcard,'photo')) && substr($vcard['photo'],0,1) == '/') {
                                $h = @parse_url($hcard);
                                if($h)
                                        $vcard['photo'] = $h['scheme'] . '://' . $h['host'] . $vcard['photo'];
                        }
-               
+
                        logger('probe_url: scrape_vcard: ' . print_r($vcard,true), LOGGER_DATA);
                }
 
@@ -561,7 +561,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
                        $vcard['nick'] = $addr_parts[0];
                }
 
-               if($twitter) {          
+               if($twitter) {
                        logger('twitter: setup');
                        $tid = basename($url);
                        $tapi = 'https://api.twitter.com/1/statuses/user_timeline.rss';
index 3b681e9918457e135a8b4bf195cea0c17e3dc253..8e77f03336bd935614062cdde64cc19d816a887f 100755 (executable)
@@ -557,7 +557,7 @@ function diaspora_decode($importer,$xml) {
 
 }
 
-       
+
 function diaspora_request($importer,$xml) {
 
        $a = get_app();
@@ -567,7 +567,7 @@ function diaspora_request($importer,$xml) {
 
        if(! $sender_handle || ! $recipient_handle)
                return;
-        
+
        $contact = diaspora_get_contact_by_handle($importer['uid'],$sender_handle);
 
        if($contact) {
@@ -752,6 +752,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)
index 59f3b1a5fcdd662be427677ee7b5e8113da7a6cd..fc167bb82be792316f8101baaf05673ba418fd37 100644 (file)
@@ -48,9 +48,9 @@ function new_contact($uid,$url,$interactive = false) {
                                $myaddr = bin2hex($a->get_baseurl() . '/profile/' . $a->user['nickname']);
                        else
                                $myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
+
                        goaway($ret['request'] . "&addr=$myaddr");
-               
+
                        // NOTREACHED
                }
        }
@@ -61,7 +61,7 @@ function new_contact($uid,$url,$interactive = false) {
                        return $result;
                }
        }
-       
+
 
 
 
index df23c2549c8cff319fdc466c147bb21dfa96329c..1de65c42cb5bda1d0be2874a070cbb401de9b5b9 100644 (file)
@@ -367,6 +367,7 @@ function lrdd($uri, $debug = false) {
        logger('lrdd: constructed url: ' . $url);
 
        $xml = fetch_url($url);
+
        $headers = $a->get_curl_headers();
 
        if (! $xml)
index 7df59f727a9cf2e09111beb96ce051deee0bca37..cc5f2a9834adabc75f8914cabcc8cbd165491d86 100644 (file)
@@ -9,7 +9,7 @@ function poller_run(&$argv, &$argc){
        if(is_null($a)) {
                $a = new App;
        }
-  
+
        if(is_null($db)) {
            @include(".htconfig.php");
        require_once("include/dba.php");
@@ -57,17 +57,17 @@ function poller_run(&$argv, &$argc){
        load_hooks();
 
        logger('poller: start');
-       
+
        // run queue delivery process in the background
 
        proc_run('php',"include/queue.php");
-       
+
        // expire any expired accounts
 
        q("UPDATE user SET `account_expired` = 1 where `account_expired` = 0 
                AND `account_expires_on` != '0000-00-00 00:00:00' 
                AND `account_expires_on` < UTC_TIMESTAMP() ");
-       
+
        // delete user and contact records for recently removed accounts
 
        $r = q("SELECT * FROM `user` WHERE `account_removed` = 1 AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
@@ -77,12 +77,12 @@ function poller_run(&$argv, &$argc){
                        q("DELETE FROM `user` WHERE `uid` = %d", intval($user['uid']));
                }
        }
-  
+
        $abandon_days = intval(get_config('system','account_abandon_days'));
        if($abandon_days < 1)
                $abandon_days = 0;
 
-       
+
 
        // once daily run birthday_updates and then expire in background
 
index 4537fd0720c80d0d4a6d66beb9797c302b5004a7..aa716f100b0e7382e196e9970648d40dddfc1800 100644 (file)
@@ -18,7 +18,7 @@
                        </ul>
                        </div>
                {{ else }}
-                       <!-- <div class="profile-edit-side-div"><a class="profile-edit-side-link icon edit" title="$editprofile" href="profiles/$profid" ></a></div> -->
+                       <div class="profile-edit-side-div"><a class="profile-edit-side-link icon edit" title="$editprofile" href="profiles" ></a></div>
                {{ endif }}
        </div>