]> git.mxchange.org Git - friendica.git/blobdiff - include/follow.php
Merge pull request #2112 from rabuzarus/2811_group_side
[friendica.git] / include / follow.php
index 10ce4f667309252b90b9bb7bb14a9d148e9da8dd..21c05c8f3ef139062963dfbd05446b96f492d9a4 100644 (file)
@@ -9,13 +9,13 @@ function update_contact($id) {
 
        $r = q("SELECT `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `network` FROM `contact` WHERE `id` = %d", intval($id));
        if (!$r)
-               return;
+               return false;
 
        $ret = probe_url($r[0]["url"]);
 
        // If probe_url fails the network code will be different
        if ($ret["network"] != $r[0]["network"])
-               return;
+               return false;
 
        $update = false;
 
@@ -29,7 +29,7 @@ function update_contact($id) {
        }
 
        if (!$update)
-               return;
+               return true;
 
        q("UPDATE `contact` SET `url` = '%s', `nurl` = '%s', `addr` = '%s', `alias` = '%s', `batch` = '%s', `notify` = '%s', `poll` = '%s', `poco` = '%s' WHERE `id` = %d",
                dbesc($ret['url']),
@@ -42,6 +42,8 @@ function update_contact($id) {
                dbesc($ret['poco']),
                intval($id)
        );
+
+       return true;
 }
 
 //
@@ -152,11 +154,7 @@ function new_contact($uid,$url,$interactive = false) {
 
        $hidden = (($ret['network'] === NETWORK_MAIL) ? 1 : 0);
 
-       if($ret['network'] === NETWORK_MAIL) {
-               $writeable = 1;
-
-       }
-       if($ret['network'] === NETWORK_DIASPORA)
+       if(in_array($ret['network'], array(NETWORK_MAIL, NETWORK_DIASPORA)))
                $writeable = 1;
 
        // check if we already have a contact
@@ -170,6 +168,11 @@ function new_contact($uid,$url,$interactive = false) {
                dbesc($ret['network'])
        );
 
+       if(!count($r))
+               $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` = '%s' LIMIT 1",
+                       intval($uid), dbesc(normalise_link($url)), dbesc($ret['network'])
+       );
+
        if(count($r)) {
                // update contact
                if($r[0]['rel'] == CONTACT_IS_FOLLOWER || ($network === NETWORK_DIASPORA && $r[0]['rel'] == CONTACT_IS_SHARING)) {
@@ -180,7 +183,6 @@ function new_contact($uid,$url,$interactive = false) {
                                intval($uid)
                        );
                }
-
        } else {
 
 
@@ -209,9 +211,7 @@ function new_contact($uid,$url,$interactive = false) {
                        return $result;
                }
 
-               $new_relation = (($ret['network'] === NETWORK_MAIL) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
-               if($ret['network'] === NETWORK_DIASPORA)
-                       $new_relation = CONTACT_IS_FOLLOWER;
+               $new_relation = ((in_array($ret['network'], array(NETWORK_MAIL, NETWORK_DIASPORA))) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
 
                // create contact record
                $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `network`, `pubkey`, `rel`, `priority`,
@@ -285,7 +285,7 @@ function new_contact($uid,$url,$interactive = false) {
 
        // pull feed and consume it, which should subscribe to the hub.
 
-       proc_run('php',"include/poller.php","$contact_id");
+       proc_run('php',"include/onepoll.php","$contact_id", "force");
 
        // create a follow slap