only allow one identity key instance per server - for now.

This commit is contained in:
Mike Macgirvin 2024-07-02 07:01:57 +10:00
parent bfdae7df3f
commit 9f0b1f40c3

View file

@ -18,6 +18,7 @@ use Code\Lib\ServiceClass;
use Code\Extend\Hook;
use Code\Render\Theme;
use Code\Lib\Url;
use Code\Lib as Zlib;
require_once('include/import.php');
require_once('include/photo_factory.php');
@ -193,13 +194,25 @@ class Import extends Controller
$eprvkey = $multibase->decode($data['privateKeyMultibase']);
if ($epubkey && $eprvkey) {
$existing = q("select * from channel where epubkey = '%s'",
dbesc($epubkey)
);
if ($existing) {
notice(t('Identity key is already in use on this instance.'));
return;
}
q("update channel set epubkey = '%s', eprivkey = '%s' where channel_id = %d",
dbesc($epubkey),
dbesc($eprvkey),
intval($channel['channel_id'])
);
q("update xchan set xchan_epubkey = '%s' where xchan_hash = '%s'",
dbesc($data['publicKeyMultibase']),
dbesc($channel['channel_hash'])
);
notice(t('Import of identity key successful.'));
PConfig::Set($channel['channel_id'], 'system', 'nomadicAP', true);
Zlib\PConfig::Set($channel['channel_id'], 'system', 'nomadicAP', true);
}
return;
}