X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Ffollow.php;h=22ff079b633949b941201d1578dd47e770b76670;hb=eba9f15daab5e4c2d246aaa7c3d9a0aacc945f01;hp=217b9d07b7b37c22de81af99793c6cd968b1146f;hpb=4b6afbf6814acde5151edc74f0b6cf1fd7685432;p=friendica.git diff --git a/include/follow.php b/include/follow.php index 217b9d07b7..22ff079b63 100644 --- a/include/follow.php +++ b/include/follow.php @@ -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 @@ -213,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`, @@ -268,24 +264,8 @@ function new_contact($uid,$url,$interactive = false) { require_once("include/Photo.php"); - $photos = import_profile_photo($ret['photo'],$uid,$contact_id); - - $r = q("UPDATE `contact` SET `photo` = '%s', - `thumb` = '%s', - `micro` = '%s', - `name-date` = '%s', - `uri-date` = '%s', - `avatar-date` = '%s' - WHERE `id` = %d", - dbesc($photos[0]), - dbesc($photos[1]), - dbesc($photos[2]), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - intval($contact_id) - ); - + // Update the avatar + update_contact_avatar($ret['photo'],$uid,$contact_id); // pull feed and consume it, which should subscribe to the hub.