aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Daemon/Notifier.php2
-rw-r--r--Zotlabs/Lib/Libsync.php12
-rw-r--r--boot.php15
3 files changed, 19 insertions, 10 deletions
diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php
index 11b890696..4ca109495 100644
--- a/Zotlabs/Daemon/Notifier.php
+++ b/Zotlabs/Daemon/Notifier.php
@@ -488,7 +488,7 @@ class Notifier {
// Now we have collected recipients (except for external mentions, FIXME)
// Let's reduce this to a set of hubs; checking that the site is not dead.
- $hubs = q("select hubloc.*, site.site_crypto, site.site_flags, site.site_dead from hubloc left join site on site_url = hubloc_url
+ $hubs = dbq("select hubloc.*, site.site_crypto, site.site_flags, site.site_dead from hubloc left join site on site_url = hubloc_url
where hubloc_hash in (" . protect_sprintf(implode(',', self::$recipients)) . ")
and hubloc_error = 0 and hubloc_deleted = 0"
);
diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php
index c4f1b20ea..23573e837 100644
--- a/Zotlabs/Lib/Libsync.php
+++ b/Zotlabs/Lib/Libsync.php
@@ -768,14 +768,13 @@ class Libsync {
// match as many fields as possible in case anything at all changed.
- $r = q("select * from hubloc where hubloc_hash = '%s' and hubloc_guid = '%s' and hubloc_guid_sig = '%s' and hubloc_id_url = '%s' and hubloc_url = '%s' and hubloc_url_sig = '%s' and hubloc_site_id = '%s' and hubloc_host = '%s' and hubloc_addr = '%s' and hubloc_callback = '%s' and hubloc_sitekey = '%s' ",
+ $r = q("select * from hubloc where hubloc_hash = '%s' and hubloc_guid = '%s' and hubloc_guid_sig = '%s' and hubloc_id_url = '%s' and hubloc_url = '%s' and hubloc_url_sig = '%s' and hubloc_host = '%s' and hubloc_addr = '%s' and hubloc_callback = '%s' and hubloc_sitekey = '%s' ",
dbesc($sender['hash']),
dbesc($sender['id']),
dbesc($sender['id_sig']),
dbesc($location['id_url']),
dbesc($location['url']),
dbesc($location['url_sig']),
- dbesc($location['site_id']),
dbesc($location['host']),
dbesc($location['address']),
dbesc($location['callback']),
@@ -784,6 +783,15 @@ class Libsync {
if ($r) {
logger('Hub exists: ' . $location['url'], LOGGER_DEBUG);
+ // generate a new hubloc_site_id if it's wrong due to historical bugs 2021-11-30
+
+ if ($r[0]['hubloc_site_id'] !== $location['site_id']) {
+ q("update hubloc set hubloc_site_id = '%s' where hubloc_id = %d",
+ dbesc(Libzot::make_xchan_hash($location['url'], $location['sitekey'])),
+ intval($r[0]['hubloc_id'])
+ );
+ }
+
// update connection timestamp if this is the site we're talking to
// This only happens when called from import_xchan
diff --git a/boot.php b/boot.php
index 6aba5e4be..81533462d 100644
--- a/boot.php
+++ b/boot.php
@@ -29,6 +29,8 @@
// composer autoloader for all namespaced Classes
use Zotlabs\Lib\Crypto;
+use Zotlabs\Lib\Libzot;
+use Zotlabs\Lib\Config;
require_once('vendor/autoload.php');
@@ -1527,8 +1529,6 @@ function check_config() {
function fix_system_urls($oldurl, $newurl) {
- require_once('include/crypto.php');
-
logger('fix_system_urls: renaming ' . $oldurl . ' to ' . $newurl);
// Basically a site rename, but this can happen if you change from http to https for instance - even if the site name didn't change
@@ -1538,7 +1538,7 @@ function fix_system_urls($oldurl, $newurl) {
// that they can clean up their hubloc tables (this includes directories).
// It's a very expensive operation so you don't want to have to do it often or after your site gets to be large.
- $r = q("select xchan.*, hubloc.* from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_url like '%s'",
+ $r = q("select xchan.*, hubloc.* from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_url like '%s' and hubloc_network = 'zot6'",
dbesc($oldurl . '%')
);
@@ -1586,13 +1586,14 @@ function fix_system_urls($oldurl, $newurl) {
dbesc($rv['xchan_hash'])
);
- $y = q("update hubloc set hubloc_addr = '%s', hubloc_url = '%s', hubloc_id_url = '%s', hubloc_url_sig = '%s', hubloc_host = '%s', hubloc_callback = '%s' where hubloc_hash = '%s' and hubloc_url = '%s'",
+ $y = q("update hubloc set hubloc_addr = '%s', hubloc_url = '%s', hubloc_id_url = '%s', hubloc_url_sig = '%s', hubloc_site_id = '%s', hubloc_host = '%s', hubloc_callback = '%s' where hubloc_hash = '%s' and hubloc_url = '%s'",
dbesc($channel_address . '@' . $rhs),
dbesc($newurl),
- dbesc(str_replace($oldurl,$newurl,$rv['hubloc_id_url'])),
- dbesc(($rv['hubloc_network'] === 'zot6') ? \Zotlabs\Lib\Libzot::sign($newurl,$c[0]['channel_prvkey']) : base64url_encode(Crypto::sign($newurl,$c[0]['channel_prvkey']))),
+ dbesc(str_replace($oldurl, $newurl,$rv['hubloc_id_url'])),
+ dbesc(Libzot::sign($newurl, $c[0]['channel_prvkey'])),
+ dbesc(Libzot::make_xchan_hash($newurl, Config::Get('system','pubkey'))),
dbesc($newhost),
- dbesc(($rv['hubloc_network'] === 'zot6') ? $newurl . '/zot' : $newurl . '/post'),
+ dbesc($newurl . '/zot'),
dbesc($rv['xchan_hash']),
dbesc($oldurl)
);