From 9f0b1f40c3114ff76c6a5646f7b3cb62be64ad57 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Tue, 2 Jul 2024 07:01:57 +1000 Subject: [PATCH] only allow one identity key instance per server - for now. --- src/Module/Import.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Module/Import.php b/src/Module/Import.php index cb924fb2d..590934161 100644 --- a/src/Module/Import.php +++ b/src/Module/Import.php @@ -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; }