]> git.mxchange.org Git - friendica.git/blobdiff - include/diaspora.php
bug in check for private email comment to public conversation prevents authenticated...
[friendica.git] / include / diaspora.php
index 2a4c8b9da4b9c3f03204d07315ffc67d760aba02..dca857a19833369cf9f5d43eca1e41e8e5820b41 100755 (executable)
@@ -451,7 +451,7 @@ function diaspora_request($importer,$xml) {
                // perhaps we were already sharing with this person. Now they're sharing with us.
                // That makes us friends.
 
-               if($contact['rel'] == CONTACT_IS_FOLLOWER) {
+               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']),
@@ -598,7 +598,7 @@ function diaspora_request($importer,$xml) {
                        `uri-date` = '%s', 
                        `avatar-date` = '%s', 
                        `blocked` = 0, 
-                       `pending` = 0,
+                       `pending` = 0
                        WHERE `id` = %d LIMIT 1
                        ",
                        dbesc($photos[0]),
@@ -611,7 +611,7 @@ function diaspora_request($importer,$xml) {
                        intval($contact_record['id'])
                );
 
-               $u = q("select * from user where id = %d limit 1",intval($importer['uid']));
+               $u = q("select * from user where uid = %d limit 1",intval($importer['uid']));
                if($u)
                        $ret = diaspora_share($u[0],$contact_record);
        }
@@ -619,6 +619,18 @@ function diaspora_request($importer,$xml) {
        return;
 }
 
+function diaspora_post_allow($importer,$contact) {
+       if(($contact['blocked']) || ($contact['readonly']))
+               return false;
+       if($contact['rel'] == CONTACT_IS_SHARING || $contact['rel'] == CONTACT_IS_FRIEND)
+               return true;
+       if($contact['rel'] == CONTACT_IS_FOLLOWER)
+               if($importer['page-flags'] == PAGE_COMMUNITY)
+                       return true;
+       return false;
+}
+
+
 function diaspora_post($importer,$xml) {
 
        $a = get_app();
@@ -629,7 +641,7 @@ function diaspora_post($importer,$xml) {
        if(! $contact)
                return;
 
-       if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) { 
+       if(! diaspora_post_allow($importer,$contact)) {
                logger('diaspora_post: Ignoring this author.');
                return 202;
        }
@@ -748,7 +760,7 @@ function diaspora_reshare($importer,$xml) {
        if(! $contact)
                return;
 
-       if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) { 
+       if(! diaspora_post_allow($importer,$contact)) {
                logger('diaspora_reshare: Ignoring this author: ' . $diaspora_handle . ' ' . print_r($xml,true));
                return 202;
        }
@@ -782,15 +794,15 @@ function diaspora_reshare($importer,$xml) {
 
        if(strlen($source_xml->post->asphoto->objectId) && ($source_xml->post->asphoto->objectId != 0) && ($source_xml->post->asphoto->image_url)) {
                $body = '[url=' . notags(unxmlify($source_xml->post->asphoto->image_url)) . '][img]' . notags(unxmlify($source_xml->post->asphoto->objectId)) . '[/img][/url]' . "\n";
-               $body = scale_diaspora_images($body,false);
+               $body = scale_external_images($body,false);
        }
        elseif($source_xml->post->asphoto->image_url) {
                $body = '[img]' . notags(unxmlify($source_xml->post->asphoto->image_url)) . '[/img]' . "\n";
-               $body = scale_diaspora_images($body);
+               $body = scale_external_images($body);
        }
        elseif($source_xml->post->status_message) {
                $body = diaspora2bb($source_xml->post->status_message->raw_message);
-               $body = scale_diaspora_images($body);
+               $body = scale_external_images($body);
 
        }
        else {
@@ -900,7 +912,7 @@ function diaspora_asphoto($importer,$xml) {
        if(! $contact)
                return;
 
-       if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) { 
+       if(! diaspora_post_allow($importer,$contact)) {
                logger('diaspora_asphoto: Ignoring this author.');
                return 202;
        }
@@ -933,11 +945,11 @@ function diaspora_asphoto($importer,$xml) {
 
        if(strlen($xml->objectId) && ($xml->objectId != 0) && ($xml->image_url)) {
                $body = '[url=' . notags(unxmlify($xml->image_url)) . '][img]' . notags(unxmlify($xml->objectId)) . '[/img][/url]' . "\n";
-               $body = scale_diaspora_images($body,false);
+               $body = scale_external_images($body,false);
        }
        elseif($xml->image_url) {
                $body = '[img]' . notags(unxmlify($xml->image_url)) . '[/img]' . "\n";
-               $body = scale_diaspora_images($body);
+               $body = scale_external_images($body);
        }
        else {
                logger('diaspora_asphoto: no photo url found.');
@@ -1001,7 +1013,7 @@ function diaspora_comment($importer,$xml,$msg) {
                return;
        }
 
-       if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) { 
+       if(! diaspora_post_allow($importer,$contact)) {
                logger('diaspora_comment: Ignoring this author.');
                return 202;
        }
@@ -1308,6 +1320,7 @@ function diaspora_conversation($importer,$xml,$msg) {
                        'language' => $importer['language'],
                        'to_name' => $importer['username'],
                        'to_email' => $importer['email'],
+                       'uid' =>$importer['importer_uid'],
                        'item' => array('subject' => $subject, 'body' => $body),
                        'source_name' => $person['name'],
                        'source_link' => $person['url'],
@@ -1445,7 +1458,7 @@ function diaspora_photo($importer,$xml,$msg) {
                return;
        }
 
-       if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) { 
+       if(! diaspora_post_allow($importer,$contact)) {
                logger('diaspora_photo: Ignoring this author.');
                return 202;
        }
@@ -1463,7 +1476,7 @@ function diaspora_photo($importer,$xml,$msg) {
 
        $link_text = '[img]' . $remote_photo_path . $remote_photo_name . '[/img]' . "\n";
 
-       $link_text = scale_diaspora_images($link_text);
+       $link_text = scale_external_images($link_text);
 
        if(strpos($parent_item['body'],$link_text) === false) {
                $r = q("update item set `body` = '%s', `visible` = 1 where `id` = %d and `uid` = %d limit 1",
@@ -1502,7 +1515,7 @@ function diaspora_like($importer,$xml,$msg) {
                return;
        }
 
-       if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) { 
+       if(! diaspora_post_allow($importer,$contact)) {
                logger('diaspora_like: Ignoring this author.');
                return 202;
        }
@@ -1790,6 +1803,9 @@ function diaspora_profile($importer,$xml) {
        if(substr($birthday,5) === substr($contact['bd'],5))
                $birthday = $contact['bd'];
 
+       // TODO: update name on item['author-name'] if the name changed. See consume_feed()
+       // Not doing this currently because D* protocol is scheduled for revision soon. 
+
        $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' , `bd` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
                dbesc($name),
                dbesc(datetime_convert()),