X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Ffollow.php;h=21c05c8f3ef139062963dfbd05446b96f492d9a4;hb=146f386e37670b64c588c65d25c9f068a0e8e066;hp=287a38b6bffb03c33e81f5856da461661e3d6be0;hpb=178b7eba1b6fea46b73ddc25dac9e669b8446a7a;p=friendica.git diff --git a/include/follow.php b/include/follow.php index 287a38b6bf..21c05c8f3e 100644 --- a/include/follow.php +++ b/include/follow.php @@ -1,5 +1,50 @@ $val) { + if (isset($r[0][$key]) AND ($r[0][$key] != "") AND ($val == "")) + $ret[$key] = $r[0][$key]; + + if (isset($r[0][$key]) AND ($ret[$key] != $r[0][$key])) + $update = true; + } + + if (!$update) + 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']), + dbesc(normalise_link($ret['url'])), + dbesc($ret['addr']), + dbesc($ret['alias']), + dbesc($ret['batch']), + dbesc($ret['notify']), + dbesc($ret['poll']), + dbesc($ret['poco']), + intval($id) + ); + + return true; +} // // Takes a $uid and a url/handle and adds a new contact @@ -109,23 +154,25 @@ 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 // the poll url is more reliable than the profile url, as we may have // indirect links or webfinger links - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `poll` = '%s' AND `network` = '%s' LIMIT 1", + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `poll` IN ('%s', '%s') AND `network` = '%s' LIMIT 1", intval($uid), dbesc($ret['poll']), + dbesc(normalise_link($ret['poll'])), 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)) { @@ -136,8 +183,7 @@ function new_contact($uid,$url,$interactive = false) { intval($uid) ); } - } - else { + } else { // check service class limits @@ -165,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`, @@ -241,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 @@ -252,7 +296,7 @@ function new_contact($uid,$url,$interactive = false) { '$photo' => $a->contact['photo'], '$thumb' => $a->contact['thumb'], '$published' => datetime_convert('UTC','UTC', 'now', ATOM_TIME), - '$item_id' => 'urn:X-dfrn:' . $a->get_hostname() . ':follow:' . random_string(), + '$item_id' => 'urn:X-dfrn:' . $a->get_hostname() . ':follow:' . get_guid(32), '$title' => '', '$type' => 'text', '$content' => t('following'),