diff options
Diffstat (limited to 'include/follow.php')
-rw-r--r-- | include/follow.php | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/include/follow.php b/include/follow.php index 54e16703d..960138743 100644 --- a/include/follow.php +++ b/include/follow.php @@ -37,9 +37,8 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) // check service class limits - $r = q("select count(*) as total from abook where abook_channel = %d and not (abook_flags & %d)>0 ", - intval($uid), - intval(ABOOK_FLAG_SELF) + $r = q("select count(*) as total from abook where abook_channel = %d and abook_self = 0 ", + intval($uid) ); if($r) $total_channels = $r[0]['total']; @@ -130,21 +129,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) } } else { - if(! ($is_http)) { - if(! intval(get_config('system','diaspora_enabled'))) { - $result['message'] = t('Protocol disabled.'); - return $result; - } - - $allowed = get_pconfig($uid,'system','diaspora_allowed'); - if($allowed === false) - $allowed = 1; - - if(! intval($allowed)) { - $result['message'] = t('Protocol blocked for this channel.'); - return $result; - } - } $their_perms = 0; $xchan_hash = ''; @@ -161,8 +145,15 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) } elseif($is_http) { $r = discover_by_url($url); + $r['allowed'] = intval(get_config('system','feed_contacts')); } if($r) { + $r['channel_id'] = $uid; + call_hooks('follow_allow',$r); + if(! $r['allowed']) { + $result['message'] = t('Protocol disabled.'); + return $result; + } $r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' limit 1", dbesc($url), dbesc($url) @@ -202,14 +193,9 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) if($is_http) { - if(! intval(get_config('system','feed_contacts'))) { - $result['message'] = t('Protocol disabled.'); - return $result; - } - $r = q("select count(*) as total from abook where abook_account = %d and ( abook_flags & %d )>0", - intval($aid), - intval(ABOOK_FLAG_FEED) + $r = q("select count(*) as total from abook where abook_account = %d and abook_feed = 1 ", + intval($aid) ); if($r) $total_feeds = $r[0]['total']; @@ -241,13 +227,13 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) if($closeness === false) $closeness = 80; - $r = q("insert into abook ( abook_account, abook_channel, abook_closeness, abook_xchan, abook_flags, abook_their_perms, abook_my_perms, abook_created, abook_updated ) + $r = q("insert into abook ( abook_account, abook_channel, abook_closeness, abook_xchan, abook_feed, abook_their_perms, abook_my_perms, abook_created, abook_updated ) values( %d, %d, %d, '%s', %d, %d, %d, '%s', '%s' ) ", intval($aid), intval($uid), intval($closeness), dbesc($xchan_hash), - intval(($is_http) ? ABOOK_FLAG_FEED : 0), + intval(($is_http) ? 1 : 0), intval(($is_http) ? $their_perms|PERMS_R_STREAM|PERMS_A_REPUBLISH : $their_perms), intval($my_perms), dbesc(datetime_convert()), |