]> git.mxchange.org Git - friendica.git/blobdiff - include/diaspora.php
Merge branch 'master', remote-tracking branch 'remotes/upstream/master'
[friendica.git] / include / diaspora.php
index 06df9c24a4513d2ddc27cd5de1c13a8e54a67db6..f7c2c5e8ec2e77ac88f9dad8b08b80b70fae82aa 100644 (file)
@@ -569,6 +569,14 @@ function diaspora_request($importer,$xml) {
                return;
        }
 
+       $g = q("select def_gid from user where uid = %d limit 1",
+               intval($importer['uid'])
+       );
+       if($g && intval($g[0]['def_gid'])) {
+               require_once('include/group.php');
+               group_add_member($importer['uid'],'',$contact_record['id'],$g[0]['def_gid']);
+       }
+
        if($importer['page-flags'] == PAGE_NORMAL) {
 
                $hash = random_string() . (string) time();   // Generate a confirm_key
@@ -706,10 +714,10 @@ function diaspora_post($importer,$xml) {
                                        continue;
 
                                $basetag = str_replace('_',' ',substr($tag,1));
-                               $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
+                               $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
                                if(strlen($str_tags))
                                        $str_tags .= ',';
-                               $str_tags .= '#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
+                               $str_tags .= '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
                                continue;
                        }
                }
@@ -872,10 +880,10 @@ function diaspora_reshare($importer,$xml) {
 
 
                                $basetag = str_replace('_',' ',substr($tag,1));
-                               $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
+                               $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
                                if(strlen($str_tags))
                                        $str_tags .= ',';
-                               $str_tags .= '#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
+                               $str_tags .= '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
                                continue;
                        }
                }
@@ -1113,10 +1121,10 @@ function diaspora_comment($importer,$xml,$msg) {
 
 
                                $basetag = str_replace('_',' ',substr($tag,1));
-                               $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
+                               $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
                                if(strlen($str_tags))
                                        $str_tags .= ',';
-                               $str_tags .= '#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
+                               $str_tags .= '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
                                continue;
                        }
                }
@@ -1172,7 +1180,7 @@ function diaspora_comment($importer,$xml,$msg) {
                proc_run('php','include/notifier.php','comment',$message_id);
        }
 
-       $myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 ",
+       $myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 AND `deleted` = 0 ",
                dbesc($parent_item['uri']),
                intval($importer['uid'])
        );
@@ -2047,8 +2055,12 @@ function diaspora_send_followup($item,$owner,$contact,$public_batch = false) {
        $myaddr = $owner['nickname'] . '@' .  substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
        $theiraddr = $contact['addr'];
 
-       $p = q("select guid from item where parent = %d limit 1",
-               $item['parent']
+       // The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always
+       // return the items ordered by `item`.`id`, in which case the wrong item is chosen as the parent.
+       // The only item with `parent` and `id` as the parent id is the parent item.
+       $p = q("select guid from item where parent = %d and id = %d limit 1",
+               intval($item['parent']),
+               intval($item['parent'])
        );
        if(count($p))
                $parent_guid = $p[0]['guid'];
@@ -2103,8 +2115,12 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
        $theiraddr = $contact['addr'];
 
 
-       $p = q("select guid from item where parent = %d limit 1",
-               $item['parent']
+       // The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always
+       // return the items ordered by `item`.`id`, in which case the wrong item is chosen as the parent.
+       // The only item with `parent` and `id` as the parent id is the parent item.
+       $p = q("select guid from item where parent = %d and id = %d limit 1",
+               intval($item['parent']),
+               intval($item['parent'])
        );
        if(count($p))
                $parent_guid = $p[0]['guid'];
@@ -2298,14 +2314,20 @@ function diaspora_transmit($owner,$contact,$slap,$public_batch) {
 
        logger('diaspora_transmit: ' . $logid . ' ' . $dest_url);
 
-       if(! intval(get_config('system','diaspora_test')))
-               post_url($dest_url . '/', $slap);
+       if(was_recently_delayed($contact['id'])) {
+               $return_code = 0;
+       }
        else {
-               logger('diaspora_transmit: test_mode');
-               return 200;
+               if(! intval(get_config('system','diaspora_test'))) {
+                       post_url($dest_url . '/', $slap);
+                       $return_code = $a->get_curl_code();
+               }
+               else {
+                       logger('diaspora_transmit: test_mode');
+                       return 200;
+               }
        }
-
-       $return_code = $a->get_curl_code();
+       
        logger('diaspora_transmit: ' . $logid . ' returns: ' . $return_code);
 
        if((! $return_code) || (($return_code == 503) && (stristr($a->get_curl_headers(),'retry-after')))) {