aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-09-11 14:33:07 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-09-11 14:33:07 -0700
commit45e1f93e564ab539941b3dccfa6b9f5654ff0203 (patch)
treeb912fe877c8ea3d83619c83ee3f774d4c904ca51
parent77807d439ec964df295d29b33455849c9a11dc92 (diff)
parente062c4e6b54c6162d118f8657eb6f81c971f0dd8 (diff)
downloadvolse-hubzilla-45e1f93e564ab539941b3dccfa6b9f5654ff0203.tar.gz
volse-hubzilla-45e1f93e564ab539941b3dccfa6b9f5654ff0203.tar.bz2
volse-hubzilla-45e1f93e564ab539941b3dccfa6b9f5654ff0203.zip
Merge https://github.com/redmatrix/redmatrix into pending_merge
Conflicts: util/messages.po
-rw-r--r--include/deliver.php4
-rw-r--r--include/zot.php52
-rw-r--r--version.inc2
3 files changed, 37 insertions, 21 deletions
diff --git a/include/deliver.php b/include/deliver.php
index 5ab44a620..26739fb06 100644
--- a/include/deliver.php
+++ b/include/deliver.php
@@ -92,12 +92,12 @@ function deliver_run($argv, $argc) {
$m = json_decode($r[0]['outq_msg'],true);
if(array_key_exists('message_list',$m)) {
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());
}
}
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());
}
$r = q("delete from outq where outq_hash = '%s'",
diff --git a/include/zot.php b/include/zot.php
index 0e00f39b4..290fd65bc 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -537,7 +537,7 @@ function zot_refresh($them, $channel = null, $force = false) {
* @returns array|null null if site is blacklisted or not found, otherwise an
* 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']) {
@@ -556,18 +556,20 @@ function zot_gethub($arr) {
return null;
}
+ $limit = (($multiple) ? '' : ' limit 1 ');
+
$r = q("select * from hubloc
where hubloc_guid = '%s' and hubloc_guid_sig = '%s'
and hubloc_url = '%s' and hubloc_url_sig = '%s'
- limit 1",
+ $limit",
dbesc($arr['guid']),
dbesc($arr['guid_sig']),
dbesc($arr['url']),
dbesc($arr['url_sig'])
);
- if($r && count($r)) {
+ if($r) {
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);
@@ -996,27 +998,38 @@ function zot_fetch($arr) {
$url = $arr['sender']['url'] . $arr['callback'];
- $ret_hub = zot_gethub($arr['sender']);
- if(! $ret_hub) {
+ // set $multiple param on zot_gethub() to return all matching hubs
+ // 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));
return;
}
- $data = array(
- 'type' => 'pickup',
- 'url' => z_root(),
- 'callback_sig' => base64url_encode(rsa_sign(z_root() . '/post',get_config('system','prvkey'))),
- 'callback' => z_root() . '/post',
- 'secret' => $arr['secret'],
- 'secret_sig' => base64url_encode(rsa_sign($arr['secret'],get_config('system','prvkey')))
- );
+ foreach($ret_hubs as $ret_hub) {
+ $data = array(
+ 'type' => 'pickup',
+ 'url' => z_root(),
+ 'callback_sig' => base64url_encode(rsa_sign(z_root() . '/post',get_config('system','prvkey'))),
+ 'callback' => z_root() . '/post',
+ '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);
- $result = zot_import($fetch, $arr['sender']['url']);
+ $fetch = zot_zot($url,$datatosend);
+
+ $result = zot_import($fetch, $arr['sender']['url']);
+
+ if($result)
+ return $result;
+ }
+
+ return;
- return $result;
}
/**
@@ -1055,6 +1068,9 @@ function zot_import($arr, $sender_url) {
$data = json_decode(crypto_unencapsulate($data,get_config('system','prvkey')),true);
}
+ if(! $data['success'])
+ return false;
+
$incoming = $data['pickup'];
$return = array();
diff --git a/version.inc b/version.inc
index 763c01a75..95854c9ac 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2015-09-10.1151
+2015-09-11.1152