aboutsummaryrefslogtreecommitdiffstats
path: root/include/zot.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-10-13 15:27:03 -0700
committerfriendica <info@friendica.com>2014-10-13 15:27:56 -0700
commit1b0390af0659e0c5534acbee97db1ef3c1e65288 (patch)
tree8b1bab439ad02518c8d3b5a4782ad80c5442cba6 /include/zot.php
parenta512d1a4aab35ac874ccbff89d84fdd6d5b3343f (diff)
downloadvolse-hubzilla-1b0390af0659e0c5534acbee97db1ef3c1e65288.tar.gz
volse-hubzilla-1b0390af0659e0c5534acbee97db1ef3c1e65288.tar.bz2
volse-hubzilla-1b0390af0659e0c5534acbee97db1ef3c1e65288.zip
new function hubloc_change_primary()
Diffstat (limited to 'include/zot.php')
-rw-r--r--include/zot.php21
1 files changed, 18 insertions, 3 deletions
diff --git a/include/zot.php b/include/zot.php
index 2d674c354..ff3bacafe 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -2,6 +2,7 @@
require_once('include/crypto.php');
require_once('include/items.php');
+require_once('include/hubloc.php');
/**
* Red implementation of zot protocol.
@@ -1714,9 +1715,14 @@ function process_location_delivery($sender,$arr,$deliveries) {
);
if($r)
$sender['key'] = $r[0]['xchan_pubkey'];
-
- $x = sync_locations($sender,$arr,true);
- logger('process_location_delivery: results: ' . print_r($x,true), LOGGER_DEBUG);
+ if(array_key_exists('locations',$arr) && $arr['locations']) {
+ $x = sync_locations($sender,$arr,true);
+ logger('process_location_delivery: results: ' . print_r($x,true), LOGGER_DEBUG);
+ if($x['changed']) {
+ $guid = random_string() . '@' . get_app()->get_hostname();
+ update_modtime($sender['hash'],$sender['guid'],$arr['locations'][0]['address'],UPDATE_FLAGS_UPDATED);
+ }
+ }
}
@@ -1837,6 +1843,7 @@ function sync_locations($sender,$arr,$absolute = false) {
dbesc(datetime_convert()),
intval($r[0]['hubloc_id'])
);
+ hubloc_change_primary($r[0]);
$what .= 'primary_hub ';
$changed = true;
}
@@ -1884,6 +1891,14 @@ function sync_locations($sender,$arr,$absolute = false) {
$what .= 'newhub ';
$changed = true;
+ if($location['primary']) {
+ $r = q("select * from hubloc where hubloc_addr = '%s' and hubloc_sitekey = '%s' limit 1",
+ dbesc($location['address']),
+ dbesc($location['sitekey'])
+ );
+ if($r)
+ hubloc_change_primary($r[0]);
+ }
}
// get rid of any hubs we have for this channel which weren't reported.