diff options
author | Mario <mario@mariovavti.com> | 2024-01-07 19:58:09 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2024-01-07 19:58:09 +0000 |
commit | 87775ae37ad7f8226f7413d28e96fd23967c7659 (patch) | |
tree | 330126a1fca83e4297b8b1d2d206b3940dbd7341 /Zotlabs/Update/_1261.php | |
parent | 256b66de41b2cd8dcdeb39fc5f080c5ff957e5d2 (diff) | |
download | volse-hubzilla-87775ae37ad7f8226f7413d28e96fd23967c7659.tar.gz volse-hubzilla-87775ae37ad7f8226f7413d28e96fd23967c7659.tar.bz2 volse-hubzilla-87775ae37ad7f8226f7413d28e96fd23967c7659.zip |
ekey and xchan_updated updates
Diffstat (limited to 'Zotlabs/Update/_1261.php')
-rw-r--r-- | Zotlabs/Update/_1261.php | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/Zotlabs/Update/_1261.php b/Zotlabs/Update/_1261.php new file mode 100644 index 000000000..da053a355 --- /dev/null +++ b/Zotlabs/Update/_1261.php @@ -0,0 +1,60 @@ +<?php +namespace Zotlabs\Update; + +use Zotlabs\Lib\Multibase; + +class _1261 { + public function run() { + + $has_sodium = function_exists('sodium_crypto_sign_keypair'); + $has_bcmath = function_exists('bcadd'); + $has_gmp = function_exists('gmp_add'); + + if (!$has_sodium) { + return UPDATE_FAILED; + } + + if (!($has_gmp || $has_bcmath)) { + hz_syslog('gothere'); + + return UPDATE_FAILED; + } + + dbq("START TRANSACTION"); + + $r1 = dbq("ALTER TABLE xchan ADD xchan_epubkey text NOT NULL"); + + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { + $r2 = dbq("ALTER TABLE xchan ADD xchan_updated timestamp NOT NULL DEFAULT '0001-01-01 00:00:00'"); + } + else { + $r2 = dbq("ALTER TABLE xchan ADD xchan_updated datetime NOT NULL DEFAULT '0001-01-01 00:00:00'"); + } + + $channels = dbq("select * from channel where true"); + if ($channels) { + foreach ($channels as $channel) { + $epubkey = (new Multibase())->publicKey($channel['channel_epubkey']); + q("update xchan set xchan_epubkey = '%s' where xchan_url = '%s'", + dbesc($epubkey), + dbesc(channel_url($channel)) + ); + } + } + + if ($r1 && $r2) { + dbq("COMMIT"); + return UPDATE_SUCCESS; + } + + dbq("ROLLBACK"); + return UPDATE_FAILED; + + } + + public function verify() { + $columns = db_columns('xchan'); + return in_array('xchan_epubkey', $columns) && in_array('xchan_updated', $columns); + } +} + |