diff options
Diffstat (limited to 'Zotlabs/Update')
-rw-r--r-- | Zotlabs/Update/_1235.php | 25 | ||||
-rw-r--r-- | Zotlabs/Update/_1236.php | 137 | ||||
-rw-r--r-- | Zotlabs/Update/_1237.php | 25 | ||||
-rw-r--r-- | Zotlabs/Update/_1238.php | 78 |
4 files changed, 265 insertions, 0 deletions
diff --git a/Zotlabs/Update/_1235.php b/Zotlabs/Update/_1235.php new file mode 100644 index 000000000..e457a35d2 --- /dev/null +++ b/Zotlabs/Update/_1235.php @@ -0,0 +1,25 @@ +<?php + +namespace Zotlabs\Update; + +class _1235 { + + function run() { + + q("START TRANSACTION"); + + $r = q("DELETE FROM app WHERE app_name = '%s' AND app_system = 1", + dbesc('Mail') + ); + + if($r) { + q("COMMIT"); + return UPDATE_SUCCESS; + } + + q("ROLLBACK"); + return UPDATE_FAILED; + + } + +} diff --git a/Zotlabs/Update/_1236.php b/Zotlabs/Update/_1236.php new file mode 100644 index 000000000..e57338e16 --- /dev/null +++ b/Zotlabs/Update/_1236.php @@ -0,0 +1,137 @@ +<?php + +namespace Zotlabs\Update; + +use Zotlabs\Lib\Libzot; + +class _1236 { + + function run() { + + $r = q("SELECT channel.channel_address, channel.channel_hash, xchan.xchan_guid, channel.channel_pubkey, channel.channel_portable_id FROM channel + LEFT JOIN xchan ON channel_hash = xchan_hash + WHERE xchan.xchan_network = 'zot' + AND channel.channel_removed = 0" + ); + + $i = 0; + + foreach($r as $rr) { + + $zot_xchan = $rr['channel_hash']; + $guid = $rr['xchan_guid']; + + $xchan = q("SELECT xchan_hash, xchan_guid_sig FROM xchan WHERE xchan_guid = '%s' AND xchan_network = 'zot6'", + dbesc($guid) + ); + + if(!$xchan) { + // This should not actually happen. + // A zot6 xchan for every channel should have been + // created in update _1226. + + // In case this failed, we will try to fix it here. + logger('No zot6 xchan found for: ' . $rr['channel_hash']); + + $zhash = $rr['channel_portable_id']; + + if(!$zhash) { + $zhash = Libzot::make_xchan_hash($rr['xchan_guid'], $rr['channel_pubkey']); + + q("UPDATE channel SET channel_portable_id = '%s' WHERE channel_hash = '%s'", + dbesc($zhash), + dbesc($zot_xchan) + ); + } + + if(!$zhash) { + logger('Could not create zot6 xchan_hash for: ' . $rr['channel_hash']); + continue; + } + + $x = q("SELECT * FROM xchan WHERE xchan_hash = '%s' LIMIT 1", + dbesc($rr['channel_hash']) + ); + + if($x) { + $rec = $x[0]; + $rec['xchan_hash'] = $zhash; + $rec['xchan_guid_sig'] = 'sha256.' . $rec['xchan_guid_sig']; + $rec['xchan_network'] = 'zot6'; + xchan_store_lowlevel($rec); + } + + // Now try again + $xchan = q("SELECT xchan_hash, xchan_guid_sig FROM xchan WHERE xchan_guid = '%s' AND xchan_network = 'zot6'", + dbesc($guid) + ); + + if(! $xchan) { + logger('Could not create zot6 xchan record for: ' . $zot_xchan); + continue; + } + + } + + $zot6_xchan = $xchan[0]['xchan_hash']; + $zot6_xchan_guid_sig = $xchan[0]['xchan_guid_sig']; + + $hubloc = q("SELECT hubloc_hash FROM hubloc WHERE hubloc_guid = '%s' AND hubloc_url = '%s' AND hubloc_network = 'zot6'", + dbesc($guid), + dbesc(z_root()) + ); + + if(! $hubloc) { + // This should not actually happen. + // A local zot6 hubloc for every channel should have been + // created in update _1226. + + // In case this failed, we will try to fix it here. + logger('No local zot6 hubloc found for: ' . $rr['channel_hash']); + + $h = q("SELECT * FROM hubloc WHERE hubloc_hash = '%s' AND hubloc_url = '%s' LIMIT 1", + dbesc($zot_xchan), + dbesc(z_root()) + ); + + if($h) { + $rec = $h[0]; + $rec['hubloc_hash'] = $zot6_xchan; + $rec['hubloc_guid_sig'] = 'sha256.' . $rec['hubloc_guid_sig']; + $rec['hubloc_network'] = 'zot6'; + $rec['hubloc_url_sig'] = 'sha256.' . $rec['hubloc_url_sig']; + $rec['hubloc_callback'] = z_root() . '/zot'; + $rec['hubloc_id_url'] = channel_url($rr); + $rec['hubloc_site_id'] = Libzot::make_xchan_hash(z_root(),get_config('system','pubkey')); + + $hubloc = hubloc_store_lowlevel($rec); + } + + if(! $hubloc) { + logger('Could not create local zot6 hubloc record for: ' . $zot_xchan); + continue; + } + } + + logger('Transforming channel: ' . $zot_xchan); + q("UPDATE channel SET channel_hash = '%s', channel_portable_id = '%s', channel_guid_sig = '%s' WHERE channel_hash = '%s'", + dbesc($zot6_xchan), + dbesc($zot_xchan), + dbesc($zot6_xchan_guid_sig), + dbesc($zot_xchan) + ); + + $i++; + + } + + if(count($r) == $i) { + z6trans_connections(); + return UPDATE_SUCCESS; + } + + return UPDATE_FAILED; + + } + +} diff --git a/Zotlabs/Update/_1237.php b/Zotlabs/Update/_1237.php new file mode 100644 index 000000000..6c998ba4f --- /dev/null +++ b/Zotlabs/Update/_1237.php @@ -0,0 +1,25 @@ +<?php + +namespace Zotlabs\Update; + +class _1237 { + + function run() { + + q("START TRANSACTION"); + + $r = q("DELETE FROM app WHERE app_name = '%s'", + dbesc('Premium Channel') + ); + + if($r) { + q("COMMIT"); + return UPDATE_SUCCESS; + } + + q("ROLLBACK"); + return UPDATE_FAILED; + + } + +} diff --git a/Zotlabs/Update/_1238.php b/Zotlabs/Update/_1238.php new file mode 100644 index 000000000..1c79cc36e --- /dev/null +++ b/Zotlabs/Update/_1238.php @@ -0,0 +1,78 @@ +<?php + +namespace Zotlabs\Update; + +class _1238 { + + function run() { + + q("START TRANSACTION"); + + $r = q("DELETE FROM app WHERE app_name = '%s'", + dbesc('Premium Channel') + ); + + // remove broken xchan entries + $r0 = dbq("DELETE FROM xchan WHERE xchan_hash = ''"); + + // remove broken hubloc entries + $r1 = dbq("DELETE FROM hubloc WHERE hubloc_hash = ''"); + + // fix legacy zot hubloc_id_url + $r2 = dbq("UPDATE hubloc + SET hubloc_id_url = CONCAT(hubloc_url, '/channel/', SUBSTRING(hubloc_addr FROM 1 FOR POSITION('@' IN hubloc_addr) -1)) + WHERE hubloc_network = 'zot' + AND hubloc_id_url = ''" + ); + + // fix singleton networks hubloc_id_url + if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { + // fix entries for activitypub which miss the xchan_url due to an earlier bug + $r3 = dbq("UPDATE xchan + SET xchan_url = xchan_hash + WHERE xchan_network = 'activitypub' + AND xchan_url = ''" + ); + + $r4 = dbq("UPDATE hubloc + LEFT JOIN xchan ON hubloc.hubloc_hash = xchan.xchan_hash + SET hubloc.hubloc_id_url = xchan.xchan_url + WHERE hubloc.hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') + AND hubloc.hubloc_id_url = '' + AND xchan.xchan_url IS NOT NULL" + ); + } + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { + // fix entries for activitypub which miss the xchan_url due to an earlier bug + $r3 = dbq("UPDATE xchan + SET xchan_url = xchan_hash + WHERE xchan_network = 'activitypub' + AND xchan_url = ''" + ); + + $r4 = dbq("UPDATE hubloc + SET hubloc_id_url = xchan_url + FROM xchan + WHERE hubloc_hash = xchan_hash + AND hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') + AND hubloc_id_url = '' + AND xchan_url IS NOT NULL" + ); + } + + if($r0 && $r1 && $r2 && $r3 && $r4) { + // remove hubloc entries where hubloc_id_url could not be fixed + $r5 = dbq("DELETE FROM hubloc WHERE hubloc_id_url = ''"); + } + + if($r0 && $r1 && $r2 && $r3 && $r4 && $r5) { + q("COMMIT"); + return UPDATE_SUCCESS; + } + + q("ROLLBACK"); + return UPDATE_FAILED; + + } + +} |