start working on the singleton setting
This commit is contained in:
parent
93123e1fa8
commit
72edc9cd6c
@ -41,6 +41,7 @@
|
||||
[tr][td]abook_feed[/td][td]indicates this connection is an RSS/Atom feed and may trigger special handling.[/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
|
||||
[tr][td]abook_incl[/td][td]connection filter allow rules separated by LF[/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
|
||||
[tr][td]abook_excl[/td][td]connection filter deny rules separated by LF[/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
|
||||
[tr][td]abook_instance[/td][td]comma separated list of site urls of all channel clones that this connection is connected with (used only for singleton networks which don't support cloning)[/td][td]text[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
|
||||
[/table]
|
||||
|
||||
|
||||
|
@ -161,6 +161,7 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
||||
}
|
||||
}
|
||||
if($r) {
|
||||
$xchan = $r[0];
|
||||
$xchan_hash = $r[0]['xchan_hash'];
|
||||
$their_perms = 0;
|
||||
}
|
||||
@ -172,7 +173,7 @@ 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);
|
||||
$x = array('channel_id' => $uid, 'follow_address' => $url, 'xchan' => $r[0], 'allowed' => 1, 'singleton' => 0);
|
||||
|
||||
call_hooks('follow_allow',$x);
|
||||
|
||||
@ -180,7 +181,7 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
||||
$result['message'] = t('Protocol disabled.');
|
||||
return $result;
|
||||
}
|
||||
|
||||
$singleton = intval($x['singleton']);
|
||||
|
||||
if((local_channel()) && $uid == local_channel()) {
|
||||
$aid = get_account_id();
|
||||
@ -221,13 +222,22 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
||||
return $result;
|
||||
}
|
||||
|
||||
$r = q("select abook_xchan from abook where abook_xchan = '%s' and abook_channel = %d limit 1",
|
||||
$r = q("select abook_xchan, abook_instance from abook where abook_xchan = '%s' and abook_channel = %d limit 1",
|
||||
dbesc($xchan_hash),
|
||||
intval($uid)
|
||||
);
|
||||
if($r) {
|
||||
$x = q("update abook set abook_their_perms = %d where abook_id = %d",
|
||||
$abook_instance = $r[0]['abook_instance'];
|
||||
|
||||
if(($singleton) && strpos($abook_instance,z_root()) === false) {
|
||||
if($abook_instance)
|
||||
$abook_instance .= ',';
|
||||
$abook_instance .= z_root();
|
||||
}
|
||||
|
||||
$x = q("update abook set abook_their_perms = %d, abook_instance = '%s' where abook_id = %d",
|
||||
intval($their_perms),
|
||||
dbesc($abook_instance),
|
||||
intval($r[0]['abook_id'])
|
||||
);
|
||||
}
|
||||
@ -237,8 +247,8 @@ 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_feed, abook_their_perms, abook_my_perms, abook_created, abook_updated )
|
||||
values( %d, %d, %d, '%s', %d, %d, %d, '%s', '%s' ) ",
|
||||
$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, abook_instance )
|
||||
values( %d, %d, %d, '%s', %d, %d, %d, '%s', '%s', '%s' ) ",
|
||||
intval($aid),
|
||||
intval($uid),
|
||||
intval($closeness),
|
||||
@ -247,7 +257,8 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
|
||||
intval(($is_http) ? $their_perms|PERMS_R_STREAM|PERMS_A_REPUBLISH : $their_perms),
|
||||
intval($my_perms),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert())
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(($singleton) ? z_root() : '')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1883,3 +1883,16 @@ function check_channelallowed($hash) {
|
||||
return $retvalue;
|
||||
}
|
||||
|
||||
function deliverable_singleton($xchan) {
|
||||
$r = q("select abook_instance from abook where abook_xchan = '%s' limit 1",
|
||||
dbesc($xchan['xchan_hash'])
|
||||
);
|
||||
if($r) {
|
||||
if(! $r[0]['abook_instance'])
|
||||
return true;
|
||||
if(strpos($r[0]['abook_instance'],z_root()) !== false)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,8 @@ require_once('include/html2plain.php');
|
||||
* purge_all channel_id
|
||||
* expire channel_id
|
||||
* relay item_id (item was relayed to owner, we will deliver it as owner)
|
||||
* single_activity item_id (deliver to a singleton network from the appropriate clone)
|
||||
* single_mail mail_id (deliver to a singleton network from the appropriate clone)
|
||||
* location channel_id
|
||||
* request channel_id xchan_hash message_id
|
||||
* rating xlink_id
|
||||
|
@ -3798,6 +3798,7 @@ function zotinfo($arr) {
|
||||
$ret['site'] = array();
|
||||
$ret['site']['url'] = z_root();
|
||||
$ret['site']['url_sig'] = base64url_encode(rsa_sign(z_root(),$e['channel_prvkey']));
|
||||
$ret['site']['zot_auth'] = z_root() . '/magic';
|
||||
|
||||
$dirmode = get_config('system','directory_mode');
|
||||
if(($dirmode === false) || ($dirmode == DIRECTORY_MODE_NORMAL))
|
||||
|
Reference in New Issue
Block a user