project "snakebite"
This commit is contained in:
parent
08b571c9d0
commit
b3ce1cd87b
@ -16,6 +16,8 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
||||
$result = array('success' => false,'message' => '');
|
||||
|
||||
$a = get_app();
|
||||
$is_red = false;
|
||||
|
||||
|
||||
if(! allowed_url($url)) {
|
||||
$result['message'] = t('Channel is blocked on this site.');
|
||||
@ -37,21 +39,15 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
||||
$ret = zot_finger($url,$channel);
|
||||
|
||||
if($ret['success']) {
|
||||
$is_red = true;
|
||||
$j = json_decode($ret['body'],true);
|
||||
}
|
||||
else {
|
||||
$result['message'] = t('Channel discovery failed. Website may be down or misconfigured.');
|
||||
logger('mod_follow: ' . $result['message']);
|
||||
return $result;
|
||||
}
|
||||
|
||||
logger('follow: ' . $url . ' ' . print_r($j,true));
|
||||
if($is_red && $j) {
|
||||
|
||||
if(! $j) {
|
||||
$result['message'] = t('Response from remote channel was not understood.');
|
||||
logger('mod_follow: ' . $result['message']);
|
||||
return $result;
|
||||
}
|
||||
$my_perms = PERMS_W_STREAM|PERMS_W_MAIL;
|
||||
|
||||
logger('follow: ' . $url . ' ' . print_r($j,true), LOGGER_DEBUG);
|
||||
|
||||
|
||||
if(! ($j['success'] && $j['guid'])) {
|
||||
@ -65,7 +61,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
||||
if(array_key_exists('connect_url',$j) && (! $confirm))
|
||||
goaway(zid($j['connect_url']));
|
||||
|
||||
|
||||
// check service class limits
|
||||
|
||||
$r = q("select count(*) as total from abook where abook_channel = %d and not (abook_flags & %d) ",
|
||||
@ -113,6 +108,25 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
||||
$their_perms = $their_perms | intval($global_perms[$k][1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
// attempt network auto-discovery
|
||||
|
||||
$my_perms = 0;
|
||||
$their_perms = 0;
|
||||
$xchan_hash = '';
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(! $xchan_hash) {
|
||||
$result['message'] = t('Channel discovery failed.');
|
||||
logger('follow: ' . $result['message']);
|
||||
return $result;
|
||||
}
|
||||
|
||||
if((local_user()) && $uid == local_user()) {
|
||||
$aid = get_account_id();
|
||||
@ -156,7 +170,7 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
||||
intval($uid),
|
||||
dbesc($xchan_hash),
|
||||
intval($their_perms),
|
||||
intval(PERMS_W_STREAM|PERMS_W_MAIL),
|
||||
intval($my_perms),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert())
|
||||
);
|
||||
@ -172,6 +186,7 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
||||
);
|
||||
if($r) {
|
||||
$result['abook'] = $r[0];
|
||||
if($is_red)
|
||||
proc_run('php', 'include/notifier.php', 'permission_update', $result['abook']['abook_id']);
|
||||
}
|
||||
|
||||
@ -188,12 +203,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
||||
group_add_member($uid,'',$xchan_hash,$g['id']);
|
||||
}
|
||||
|
||||
// Then send a ping/message to the other side
|
||||
|
||||
|
||||
$result['success'] = true;
|
||||
return $result;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user