diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/follow.php | 26 | ||||
-rw-r--r-- | include/text.php | 2 |
2 files changed, 19 insertions, 9 deletions
diff --git a/include/follow.php b/include/follow.php index 960138743..ae0f9f041 100644 --- a/include/follow.php +++ b/include/follow.php @@ -133,27 +133,27 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) $their_perms = 0; $xchan_hash = ''; + $r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' limit 1", dbesc($url), dbesc($url) ); + if(! $r) { // attempt network auto-discovery if(strpos($url,'@') && (! $is_http)) { - $r = discover_by_webbie($url); + $d = discover_by_webbie($url); } 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']) { + if(get_config('system','feed_contacts')) + $d = discover_by_url($url); + else { $result['message'] = t('Protocol disabled.'); return $result; } + } + if($d) { $r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' limit 1", dbesc($url), dbesc($url) @@ -172,6 +172,16 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) return $result; } + $x = array('channel_id' => $uid, 'follow_address' => $url, 'xchan' => $r[0], 'allowed' => 1); + + call_hooks('follow_allow',$x); + + if(! $x['allowed']) { + $result['message'] = t('Protocol disabled.'); + return $result; + } + + if((local_channel()) && $uid == local_channel()) { $aid = get_account_id(); $hash = get_observer_hash(); diff --git a/include/text.php b/include/text.php index 9246370ba..25743e872 100644 --- a/include/text.php +++ b/include/text.php @@ -1975,7 +1975,7 @@ function xchan_query(&$items,$abook = true,$effective_uid = 0) { $chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash where xchan_hash in (" . implode(',', $arr) . ") and hubloc_primary = 1"); } - $xchans = q("select * from xchan where xchan_hash in (" . implode(',',$arr) . ") and xchan_network in ('rss','unknown')"); + $xchans = q("select * from xchan where xchan_hash in (" . protect_sprintf(implode(',',$arr)) . ") and xchan_network in ('rss','unknown')"); if(! $chans) $chans = $xchans; else |