mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 06:35:15 +00:00
service class check for feeds. Note limit is account based, not channel based.
This commit is contained in:
parent
d400514289
commit
89d5c42df1
1 changed files with 33 additions and 21 deletions
|
@ -17,7 +17,7 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
|||
|
||||
$a = get_app();
|
||||
$is_red = false;
|
||||
|
||||
$is_http = ((strpos($url,'://') !== false) ? true : false);
|
||||
|
||||
if(! allowed_url($url)) {
|
||||
$result['message'] = t('Channel is blocked on this site.');
|
||||
|
@ -29,13 +29,29 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
|||
return $result;
|
||||
}
|
||||
|
||||
|
||||
// check service class limits
|
||||
|
||||
$r = q("select count(*) as total from abook where abook_channel = %d and not (abook_flags & %d) ",
|
||||
intval($uid),
|
||||
intval(ABOOK_FLAG_SELF)
|
||||
);
|
||||
if($r)
|
||||
$total_channels = $r[0]['total'];
|
||||
|
||||
if(! service_class_allows($uid,'total_channels',$total_channels)) {
|
||||
$result['message'] = upgrade_message();
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
$arr = array('url' => $url, 'channel' => array());
|
||||
|
||||
call_hooks('follow', $arr);
|
||||
|
||||
if($arr['channel']['success'])
|
||||
$ret = $arr['channel'];
|
||||
elseif(strpos($url,'://') === false)
|
||||
elseif($is_http)
|
||||
$ret = zot_finger($url,$channel);
|
||||
|
||||
if($ret && $ret['success']) {
|
||||
|
@ -61,20 +77,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) ",
|
||||
intval($uid),
|
||||
intval(ABOOK_FLAG_SELF)
|
||||
);
|
||||
if($r)
|
||||
$total_channels = $r[0]['total'];
|
||||
|
||||
if(! service_class_allows($uid,'total_channels',$total_channels)) {
|
||||
$result['message'] = upgrade_message();
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
// do we have an xchan and hubloc?
|
||||
// If not, create them.
|
||||
|
@ -120,7 +122,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
|||
$my_perms = 0;
|
||||
$their_perms = 0;
|
||||
$xchan_hash = '';
|
||||
$is_http = false;
|
||||
|
||||
$r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' limit 1",
|
||||
dbesc($url),
|
||||
|
@ -132,9 +133,8 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
|||
if(strpos($url,'@')) {
|
||||
$r = discover_by_webbie($url);
|
||||
}
|
||||
elseif(strpos($url,'://')) {
|
||||
elseif($is_http) {
|
||||
$r = discover_by_url($url);
|
||||
$is_http = true;
|
||||
}
|
||||
if($r) {
|
||||
$r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' limit 1",
|
||||
|
@ -148,7 +148,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
|||
$their_perms = 0;
|
||||
$my_perms = PERMS_W_STREAM|PERMS_W_MAIL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(! $xchan_hash) {
|
||||
|
@ -175,7 +174,20 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
|||
$hash = $r[0]['channel_hash'];
|
||||
$default_group = $r[0]['channel_default_group'];
|
||||
}
|
||||
|
||||
|
||||
if($is_http) {
|
||||
$r = q("select count(*) as total from abook where abook_account = %d and abook_network = 'rss'",
|
||||
intval($aid)
|
||||
);
|
||||
if($r)
|
||||
$total_feeds = $r[0]['total'];
|
||||
|
||||
if(! service_class_allows($uid,'total_feeds',$total_feeds)) {
|
||||
$result['message'] = upgrade_message();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
if($hash == $xchan_hash) {
|
||||
$result['message'] = t('Cannot connect to yourself.');
|
||||
return $result;
|
||||
|
|
Loading…
Reference in a new issue