another tactic to deal with orphan hublocs from re-installs, or at least allow the descendant channel to survive
This commit is contained in:
parent
05e0ed5173
commit
e062c4e6b5
@ -92,12 +92,12 @@ function deliver_run($argv, $argc) {
|
|||||||
$m = json_decode($r[0]['outq_msg'],true);
|
$m = json_decode($r[0]['outq_msg'],true);
|
||||||
if(array_key_exists('message_list',$m)) {
|
if(array_key_exists('message_list',$m)) {
|
||||||
foreach($m['message_list'] as $mm) {
|
foreach($m['message_list'] as $mm) {
|
||||||
$msg = array('body' => json_encode(array('pickup' => array(array('notify' => $notify,'message' => $mm)))));
|
$msg = array('body' => json_encode(array('success' => true, 'pickup' => array(array('notify' => $notify,'message' => $mm)))));
|
||||||
zot_import($msg,z_root());
|
zot_import($msg,z_root());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$msg = array('body' => json_encode(array('pickup' => array(array('notify' => $notify,'message' => $m)))));
|
$msg = array('body' => json_encode(array('success' => true, 'pickup' => array(array('notify' => $notify,'message' => $m)))));
|
||||||
zot_import($msg,z_root());
|
zot_import($msg,z_root());
|
||||||
}
|
}
|
||||||
$r = q("delete from outq where outq_hash = '%s'",
|
$r = q("delete from outq where outq_hash = '%s'",
|
||||||
|
@ -543,7 +543,7 @@ function zot_refresh($them, $channel = null, $force = false) {
|
|||||||
* @returns array|null null if site is blacklisted or not found, otherwise an
|
* @returns array|null null if site is blacklisted or not found, otherwise an
|
||||||
* array with an hubloc record
|
* array with an hubloc record
|
||||||
*/
|
*/
|
||||||
function zot_gethub($arr) {
|
function zot_gethub($arr,$multiple = false) {
|
||||||
|
|
||||||
if($arr['guid'] && $arr['guid_sig'] && $arr['url'] && $arr['url_sig']) {
|
if($arr['guid'] && $arr['guid_sig'] && $arr['url'] && $arr['url_sig']) {
|
||||||
|
|
||||||
@ -562,18 +562,20 @@ function zot_gethub($arr) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$limit = (($multiple) ? '' : ' limit 1 ');
|
||||||
|
|
||||||
$r = q("select * from hubloc
|
$r = q("select * from hubloc
|
||||||
where hubloc_guid = '%s' and hubloc_guid_sig = '%s'
|
where hubloc_guid = '%s' and hubloc_guid_sig = '%s'
|
||||||
and hubloc_url = '%s' and hubloc_url_sig = '%s'
|
and hubloc_url = '%s' and hubloc_url_sig = '%s'
|
||||||
limit 1",
|
$limit",
|
||||||
dbesc($arr['guid']),
|
dbesc($arr['guid']),
|
||||||
dbesc($arr['guid_sig']),
|
dbesc($arr['guid_sig']),
|
||||||
dbesc($arr['url']),
|
dbesc($arr['url']),
|
||||||
dbesc($arr['url_sig'])
|
dbesc($arr['url_sig'])
|
||||||
);
|
);
|
||||||
if($r && count($r)) {
|
if($r) {
|
||||||
logger('zot_gethub: found', LOGGER_DEBUG);
|
logger('zot_gethub: found', LOGGER_DEBUG);
|
||||||
return $r[0];
|
return (($multiple) ? $r : $r[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger('zot_gethub: not found: ' . print_r($arr,true), LOGGER_DEBUG);
|
logger('zot_gethub: not found: ' . print_r($arr,true), LOGGER_DEBUG);
|
||||||
@ -1017,27 +1019,38 @@ function zot_fetch($arr) {
|
|||||||
|
|
||||||
$url = $arr['sender']['url'] . $arr['callback'];
|
$url = $arr['sender']['url'] . $arr['callback'];
|
||||||
|
|
||||||
$ret_hub = zot_gethub($arr['sender']);
|
// set $multiple param on zot_gethub() to return all matching hubs
|
||||||
if(! $ret_hub) {
|
// This allows us to recover from re-installs when a redundant (but invalid) hubloc for
|
||||||
|
// this identity is widely dispersed throughout the network.
|
||||||
|
|
||||||
|
$ret_hubs = zot_gethub($arr['sender'],true);
|
||||||
|
if(! $ret_hubs) {
|
||||||
logger('zot_fetch: no hub: ' . print_r($arr['sender'],true));
|
logger('zot_fetch: no hub: ' . print_r($arr['sender'],true));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = array(
|
foreach($ret_hubs as $ret_hub) {
|
||||||
'type' => 'pickup',
|
$data = array(
|
||||||
'url' => z_root(),
|
'type' => 'pickup',
|
||||||
'callback_sig' => base64url_encode(rsa_sign(z_root() . '/post',get_config('system','prvkey'))),
|
'url' => z_root(),
|
||||||
'callback' => z_root() . '/post',
|
'callback_sig' => base64url_encode(rsa_sign(z_root() . '/post',get_config('system','prvkey'))),
|
||||||
'secret' => $arr['secret'],
|
'callback' => z_root() . '/post',
|
||||||
'secret_sig' => base64url_encode(rsa_sign($arr['secret'],get_config('system','prvkey')))
|
'secret' => $arr['secret'],
|
||||||
);
|
'secret_sig' => base64url_encode(rsa_sign($arr['secret'],get_config('system','prvkey')))
|
||||||
|
);
|
||||||
|
|
||||||
$datatosend = json_encode(crypto_encapsulate(json_encode($data),$ret_hub['hubloc_sitekey']));
|
$datatosend = json_encode(crypto_encapsulate(json_encode($data),$ret_hub['hubloc_sitekey']));
|
||||||
|
|
||||||
$fetch = zot_zot($url,$datatosend);
|
$fetch = zot_zot($url,$datatosend);
|
||||||
$result = zot_import($fetch, $arr['sender']['url']);
|
|
||||||
|
$result = zot_import($fetch, $arr['sender']['url']);
|
||||||
|
|
||||||
|
if($result)
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1076,6 +1089,9 @@ function zot_import($arr, $sender_url) {
|
|||||||
$data = json_decode(crypto_unencapsulate($data,get_config('system','prvkey')),true);
|
$data = json_decode(crypto_unencapsulate($data,get_config('system','prvkey')),true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(! $data['success'])
|
||||||
|
return false;
|
||||||
|
|
||||||
$incoming = $data['pickup'];
|
$incoming = $data['pickup'];
|
||||||
|
|
||||||
$return = array();
|
$return = array();
|
||||||
|
368
util/messages.po
368
util/messages.po
File diff suppressed because it is too large
Load Diff
@ -1 +1 @@
|
|||||||
2015-09-10.1151
|
2015-09-11.1152
|
||||||
|
Reference in New Issue
Block a user