mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
Revert "DB update 1260 - REQUIRES SODIUM PHP EXTENSION!!!"
This reverts commit 5ee4f37b8d
This commit is contained in:
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
namespace Zotlabs\Update;
|
||||
|
||||
class _1260 {
|
||||
public function run() {
|
||||
|
||||
$has_sodium = function_exists('sodium_crypto_sign_keypair');
|
||||
|
||||
if (!$has_sodium) {
|
||||
return UPDATE_FAILED;
|
||||
}
|
||||
|
||||
q("START TRANSACTION");
|
||||
|
||||
$r1 = q("ALTER TABLE channel ADD channel_epubkey text NOT NULL");
|
||||
$r2 = q("ALTER TABLE channel ADD channel_eprvkey text NOT NULL");
|
||||
|
||||
$channels = q("select channel_id from channel where true");
|
||||
if ($channels) {
|
||||
foreach ($channels as $channel) {
|
||||
$keys = sodium_crypto_sign_keypair();
|
||||
$pubkey = sodium_bin2base64(sodium_crypto_sign_publickey($keys), SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING);
|
||||
$prvkey = sodium_bin2base64(sodium_crypto_sign_secretkey($keys), SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING);
|
||||
q("update channel set channel_epubkey = '%s', channel_eprvkey = '%s' where channel_id = %d",
|
||||
dbesc($pubkey),
|
||||
dbesc($prvkey),
|
||||
intval($channel['channel_id'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($r1 && $r2) {
|
||||
q("COMMIT");
|
||||
return UPDATE_SUCCESS;
|
||||
}
|
||||
|
||||
q("ROLLBACK");
|
||||
return UPDATE_FAILED;
|
||||
}
|
||||
|
||||
public function verify() {
|
||||
$columns = db_columns('channel');
|
||||
return in_array('channel_epubkey', $columns) && in_array('channel_eprvkey', $columns);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user