aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-04-01 07:44:07 +0000
committerMario <mario@mariovavti.com>2020-04-01 07:44:07 +0000
commitffe429be65e8d6198579d3dd987053387799ca78 (patch)
tree1c88542037942394beea6bb6a15db7cab80941cc
parentb739f91caa1522522a4ce093d7c63f0f4c777085 (diff)
downloadvolse-hubzilla-ffe429be65e8d6198579d3dd987053387799ca78.tar.gz
volse-hubzilla-ffe429be65e8d6198579d3dd987053387799ca78.tar.bz2
volse-hubzilla-ffe429be65e8d6198579d3dd987053387799ca78.zip
transition connections to zot6 if their site has been updated
-rw-r--r--Zotlabs/Daemon/Cron_daily.php2
-rw-r--r--Zotlabs/Module/Connections.php2
-rw-r--r--Zotlabs/Update/_1236.php8
-rw-r--r--include/connections.php64
4 files changed, 72 insertions, 4 deletions
diff --git a/Zotlabs/Daemon/Cron_daily.php b/Zotlabs/Daemon/Cron_daily.php
index 452ef45f1..2cf0c9119 100644
--- a/Zotlabs/Daemon/Cron_daily.php
+++ b/Zotlabs/Daemon/Cron_daily.php
@@ -96,7 +96,9 @@ class Cron_daily {
Master::Summon(array('Cli_suggest'));
remove_obsolete_hublocs();
+
z6_discover();
+ z6trans_connections();
call_hooks('cron_daily',datetime_convert());
diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php
index 029601867..7dc301623 100644
--- a/Zotlabs/Module/Connections.php
+++ b/Zotlabs/Module/Connections.php
@@ -34,7 +34,7 @@ class Connections extends \Zotlabs\Web\Controller {
}
nav_set_selected('Connections');
-
+
$active = false;
$blocked = false;
$hidden = false;
diff --git a/Zotlabs/Update/_1236.php b/Zotlabs/Update/_1236.php
index d40cc9e25..6b4e7b299 100644
--- a/Zotlabs/Update/_1236.php
+++ b/Zotlabs/Update/_1236.php
@@ -105,10 +105,12 @@ class _1236 {
}
- if(count($r) == $i)
+ if(count($r) == $i) {
+ z6trans_connections();
return UPDATE_SUCCESS;
- else
- return UPDATE_FAILED;
+ }
+
+ return UPDATE_FAILED;
}
diff --git a/include/connections.php b/include/connections.php
index 51df18b70..c7ec163c8 100644
--- a/include/connections.php
+++ b/include/connections.php
@@ -772,3 +772,67 @@ function vcard_query(&$r) {
}
}
}
+
+function z6trans_connections() {
+
+ $r = q("SELECT DISTINCT abook.abook_xchan, hubloc.hubloc_addr, hubloc.hubloc_url, hubloc.hubloc_guid, site.site_project, site.site_version FROM abook
+ LEFT JOIN hubloc ON abook_xchan = hubloc_hash
+ LEFT JOIN site ON hubloc_url = site_url
+ WHERE abook.abook_self = 0 AND hubloc.hubloc_network = 'zot'
+ AND hubloc.hubloc_deleted = 0 AND site.site_dead = 0"
+ );
+
+ foreach($r as $rr) {
+ if(stripos($rr['site_project'], 'hubzilla') !== false && version_compare($rr['site_version'], '4.7.4', '>=')) {
+
+ $zot_xchan = $rr['abook_xchan'];
+ $guid = $rr['hubloc_guid'];
+ $hub_url = $rr['hubloc_url'];
+ $addr = $rr['hubloc_addr'];
+
+ $x = q("SELECT hubloc_hash FROM hubloc
+ WHERE hubloc_guid = '%s' AND hubloc_url = '%s' AND hubloc_network = 'zot6' AND hubloc_deleted = 0",
+ dbesc($guid),
+ dbesc($hub_url)
+ );
+
+ if(!$x) {
+ logger("z6trans_connections: zot6 hubloc for $addr not found");
+ discover_by_webbie($addr,'zot6');
+ continue;
+ }
+
+ $zot6_xchan = $x[0]['hubloc_hash'];
+
+ logger("z6trans_connections: transition $zot_xchan to $zot6_xchan");
+
+ q("START TRANSACTION");
+
+ $q1 = q("UPDATE abook set abook_xchan = '%s' WHERE abook_xchan = '%s'",
+ dbesc($zot6_xchan),
+ dbesc($zot_xchan)
+ );
+
+ $q2 = q("UPDATE abconfig set xchan = '%s' WHERE xchan = '%s'",
+ dbesc($zot6_xchan),
+ dbesc($zot_xchan)
+ );
+
+ $q3 = q("UPDATE pgrp_member set xchan = '%s' WHERE xchan = '%s'",
+ dbesc($zot6_xchan),
+ dbesc($zot_xchan)
+ );
+
+ if($q1 && $q2 && $q3) {
+ q("COMMIT");
+ logger("z6trans_connections: completed");
+ continue;
+ }
+
+ logger("z6trans_connections: failed - performing rollback");
+ q("ROLLBACK");
+
+ }
+ }
+
+}