]> git.mxchange.org Git - friendica.git/commitdiff
set writable flag on dfrn_poll
authorFriendika <info@friendika.com>
Mon, 11 Apr 2011 02:29:21 +0000 (19:29 -0700)
committerFriendika <info@friendika.com>
Mon, 11 Apr 2011 02:29:21 +0000 (19:29 -0700)
include/poller.php
mod/dfrn_notify.php
mod/dfrn_poll.php

index 9362c28b31bb4997127cf1773a992069a2720148..cb246158485dd3ce2dd633db0dd8f147a8921ba3 100644 (file)
@@ -165,11 +165,15 @@ function poller_run($argv, $argc){
                                if(intval($contact['duplex']) && $contact['dfrn-id'])
                                        $idtosend = '0:' . $orig_id;
                                if(intval($contact['duplex']) && $contact['issued-id'])
-                                       $idtosend = '1:' . $orig_id;            
+                                       $idtosend = '1:' . $orig_id;
+
+                               // they have permission to write to us. We already filtered this in the contact query.
+                               $perm = 'rw';
 
                                $url = $contact['poll'] . '?dfrn_id=' . $idtosend 
                                        . '&dfrn_version=' . DFRN_PROTOCOL_VERSION 
-                                       . '&type=data&last_update=' . $last_update ;
+                                       . '&type=data&last_update=' . $last_update 
+                                       . '&perm=' . $perm ;
        
                                $xml = fetch_url($url);
 
@@ -250,13 +254,14 @@ function poller_run($argv, $argc){
                                        $final_dfrn_id = substr($final_dfrn_id,2);
 
                                if($final_dfrn_id != $orig_id) {
-       
+                                       logger('poller: ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);    
                                        // did not decode properly - cannot trust this site 
                                        continue;
                                }
 
                                $postvars['dfrn_id'] = $idtosend;
                                $postvars['dfrn_version'] = DFRN_PROTOCOL_VERSION;
+                               $postvars['perm'] = 'rw';
 
                                $xml = post_url($contact['poll'],$postvars);
                        }
index dd6866b385c8e084be3a2e7845ff9a6d28491310..f6f68d348c4e53e82c863aa180a1cd1f8743e3ee 100644 (file)
@@ -80,6 +80,14 @@ function dfrn_notify_post(&$a) {
 
        $importer = $r[0];
 
+       if(($writable != (-1)) && ($writable != $importer['writable'])) {
+               q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d LIMIT 1",
+                       intval($writable),
+                       intval($importer['id'])
+               );
+               $importer['writable'] = $writable;
+       }
+
        logger('dfrn_notify: received notify from ' . $importer['name'] . ' for ' . $importer['username']);
        logger('dfrn_notify: data: ' . $data, LOGGER_DATA);
 
@@ -124,8 +132,6 @@ function dfrn_notify_post(&$a) {
        }
 
 
-
-
        if($importer['readonly']) {
                // We aren't receiving stuff from this person. But we will quietly ignore them
                // rather than a blatant "go away" message.
index a2fdb9ee13c532e0d85b0dc1ed944fde7e841cdc..d68841d05db43178cdf71ca169d93581f7716540 100644 (file)
@@ -297,6 +297,7 @@ function dfrn_poll_post(&$a) {
        if(! count($r))
                killme();
 
+       $contact = $r[0];
        $owner_uid = $r[0]['uid'];
        $contact_id = $r[0]['id']; 
 
@@ -330,6 +331,23 @@ function dfrn_poll_post(&$a) {
                // NOTREACHED
        }
        else {
+
+               // Update the writable flag if it changed               
+
+               if($dfrn_version >= 2.21) {
+                       if($perm === 'rw')
+                               $writable = 1;
+                       else
+                               $writable = 0;
+
+                       if($writable !=  $contact['writable]) {
+                               q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d LIMIT 1",
+                                       intval($writable),
+                                       intval($contact_id)
+                               );
+                       }
+               }                               
+
                header("Content-type: application/atom+xml");
                $o = get_feed_for($a,$dfrn_id, $a->argv[1], $last_update, $direction);
                echo $o;