adasd
This commit is contained in:
@@ -2072,6 +2072,33 @@ class ApiKernel
|
||||
$user = $this->requireAuth();
|
||||
$this->ensureRole($user, ['owner', 'admin']);
|
||||
$customerId = (int)($user['customer_id'] ?? 0);
|
||||
$setup = $this->getBridgeSetupData($customerId);
|
||||
$mode = strtolower((string)($this->in['mode'] ?? $this->in['db_mode'] ?? ($setup['mode'] ?? 'bridge')));
|
||||
$importType = strtolower((string)($this->in['import_type'] ?? $this->in['bridge_import'] ?? ($setup['import_type'] ?? 'schema')));
|
||||
$tablesAllow = $this->normalizeBridgeTables($this->in['tables'] ?? ($setup['tables'] ?? []));
|
||||
|
||||
if ($mode === 'direct') {
|
||||
$direct = [
|
||||
'host' => trim((string)($this->in['direct_host'] ?? ($setup['direct']['host'] ?? ''))),
|
||||
'port' => (int)($this->in['direct_port'] ?? ($setup['direct']['port'] ?? 3306)),
|
||||
'database' => trim((string)($this->in['direct_database'] ?? ($setup['direct']['database'] ?? ''))),
|
||||
'user' => trim((string)($this->in['direct_user'] ?? ($setup['direct']['user'] ?? ''))),
|
||||
'password' => (string)($this->in['direct_password'] ?? ($setup['direct']['password'] ?? '')),
|
||||
'charset' => trim((string)($this->in['direct_charset'] ?? ($setup['direct']['charset'] ?? 'utf8mb4'))) ?: 'utf8mb4',
|
||||
];
|
||||
try {
|
||||
$schema = $this->fetchSchemaFromDirect($direct, $tablesAllow);
|
||||
} catch (Throwable $e) {
|
||||
$this->fail('DB request failed', $e->getMessage(), 502);
|
||||
return;
|
||||
}
|
||||
$this->respond([
|
||||
'ok' => true,
|
||||
'tables' => $schema['tables'] ?? [],
|
||||
'fetched' => $schema['fetched'] ?? date(DATE_ATOM),
|
||||
]);
|
||||
}
|
||||
|
||||
$bridgeUrl = trim((string)($this->in['bridge_url'] ?? ''));
|
||||
$bridgeToken = trim((string)($this->in['bridge_token'] ?? ''));
|
||||
if ($bridgeUrl === '' || $bridgeToken === '') {
|
||||
@@ -2088,6 +2115,29 @@ class ApiKernel
|
||||
$this->fail('Bridge request failed', $e->getMessage(), 502);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($importType === 'settings') {
|
||||
$hint = is_array($schema['setup_hint'] ?? null) ? $schema['setup_hint'] : [];
|
||||
$directHint = is_array($hint['direct'] ?? null) ? $hint['direct'] : [];
|
||||
$direct = [
|
||||
'host' => trim((string)($directHint['host'] ?? '')),
|
||||
'port' => (int)($directHint['port'] ?? 3306),
|
||||
'database' => trim((string)($directHint['database'] ?? '')),
|
||||
'user' => trim((string)($directHint['user'] ?? '')),
|
||||
'password' => (string)($directHint['password'] ?? ''),
|
||||
'charset' => trim((string)($directHint['charset'] ?? 'utf8mb4')) ?: 'utf8mb4',
|
||||
];
|
||||
if ($direct['host'] === '' || $direct['database'] === '' || $direct['user'] === '') {
|
||||
$this->fail('Bridge lieferte keine DB-Settings', null, 422);
|
||||
}
|
||||
try {
|
||||
$schema = $this->fetchSchemaFromDirect($direct, $tablesAllow);
|
||||
} catch (Throwable $e) {
|
||||
$this->fail('DB request failed', $e->getMessage(), 502);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->respond([
|
||||
'ok' => true,
|
||||
'tables' => $schema['tables'] ?? [],
|
||||
|
||||
Reference in New Issue
Block a user