network discovery on follow

This commit is contained in:
friendica 2012-10-31 21:42:20 -07:00
parent 78f64c90a3
commit 77c30972cb
3 changed files with 15 additions and 7 deletions

View File

@ -2,28 +2,28 @@
// //
// Takes a $uid and a url/handle and adds a new channel // Takes a $uid and the channel associated with the uid, and a url/handle and adds a new channel
// Returns an array // Returns an array
// $return['success'] boolean true if successful // $return['success'] boolean true if successful
// $return['abook_id'] Address book ID if successful // $return['abook_id'] Address book ID if successful
// $return['message'] error text if success is false. // $return['message'] error text if success is false.
require_once('include/zot.php');
function new_contact($uid,$url,$channel.$interactive = false) {
function new_contact($uid,$url,$interactive = false) {
$result = array('success' => false,'message' => ''); $result = array('success' => false,'message' => '');
$a = get_app(); $a = get_app();
if(! allowed_url($url)) { if(! allowed_url($url)) {
$result['message'] = t('Disallowed profile URL.'); $result['message'] = t('Channel is blocked on this site.');
return $result; return $result;
} }
if(! $url) { if(! $url) {
$result['message'] = t('Connect URL missing.'); $result['message'] = t('Channel location missing.');
return $result; return $result;
} }
@ -34,9 +34,15 @@ function new_contact($uid,$url,$interactive = false) {
if(x($arr['contact'],'name')) if(x($arr['contact'],'name'))
$ret = $arr['contact']; $ret = $arr['contact'];
else else
$ret = zot_probe_url($url); $ret = zot_finger($url,$channel,false);
if($ret['success']) {
$j = json_decode($ret['body']);
}
// logger('follow: ' . print_r($j,true));
killme();
if($ret['network'] === NETWORK_DFRN) { if($ret['network'] === NETWORK_DFRN) {

View File

@ -74,6 +74,8 @@ function zot_notify($channel,$url) {
function zot_finger($webbie,$channel) { function zot_finger($webbie,$channel) {
logger('zot_finger:' . print_r($channel,true));
if(strpos($webbie,'@') === false) { if(strpos($webbie,'@') === false) {
$address = $webbie; $address = $webbie;
$host = get_app()->get_hostname(); $host = get_app()->get_hostname();

View File

@ -16,7 +16,7 @@ function follow_init(&$a) {
$return_url = $_SESSION['return_url']; $return_url = $_SESSION['return_url'];
$result = new_contact($uid,$url,true); $result = new_contact($uid,$url,$a->get_channel(),true);
if($result['success'] == false) { if($result['success'] == false) {
if($result['message']) if($result['message'])