Files
c-relay-pg/admin/api/config.php
T
Laan Tungir ca7a4b6722 v2.1.36 - Unified relay table, caching/backfill separation, inbox defaults, profile gating, and UI fixes
- Added caching_relays unified table with live_enabled/backfill_enabled columns
- Separated --reset-backfill from --start-caching as independent flags
- Removed redundant caching_enabled master setting; daemon derives from live/backfill
- Set caching_inbox_enabled=true by default; removed Inbox toggle from Backfill page
- Set caching_live_strategy=cache_all by default
- Fixed outbox relay discovery to store ALL discovered relays, not just covering set
- Added store_kind_0_information config (default: true) to gate profile sync trigger
- Regenerated pg_schema.h from pg_schema.sql to include caching_relays table
- Fixed process toggle button styling to match monochrome aesthetic
- Fixed radio button styling to match black/white/red theme
- Simplified Backfill page: removed Service Status and Inbox Status sections
- Backfill status now respects config setting, not just daemon state
- Admin config API now bumps caching_config_generation for caching-related changes
- make_and_restart_relay.sh now resets PostgreSQL schema on fresh restart
2026-08-03 19:37:09 -04:00

44 lines
1.7 KiB
PHP

<?php
/** admin2/api/config.php — Config table read/edit (all keys). */
require_once __DIR__ . '/../lib/helpers.php';
$pdo = db();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$input = json_decode(file_get_contents('php://input'), true);
$key = $input['key'] ?? '';
$value = $input['value'] ?? '';
if (!$key) json_response(['error' => 'Missing key']);
try {
$pdo->beginTransaction();
$updated = $pdo->prepare("UPDATE config SET value = ?, updated_at = EXTRACT(EPOCH FROM NOW())::BIGINT WHERE key = ?")
->execute([$value, $key]);
if (!$updated) {
throw new RuntimeException("Failed to update $key");
}
// The caching daemon polls this generation value and reloads config
// independently of whether the relay's main process is restarted.
if (in_array($key, [
'caching_backfill_enabled',
'caching_inbox_enabled',
'caching_live_enabled',
'caching_live_strategy',
'caching_live_kinds',
'caching_live_since_seconds',
'caching_live_limit',
'caching_backfill_page_size',
'caching_backfill_tick_interval_ms'
], true)) {
$pdo->exec("UPDATE config SET value = (COALESCE(value::int, 0) + 1)::text, updated_at = EXTRACT(EPOCH FROM NOW())::BIGINT WHERE key = 'caching_config_generation'");
}
$pdo->commit();
json_response(['message' => "Updated $key"]);
} catch (Throwable $e) {
if ($pdo->inTransaction()) $pdo->rollBack();
json_response(['error' => $e->getMessage()], 500);
}
}
$rows = $pdo->query("SELECT key, value FROM config ORDER BY key")->fetchAll();
json_response(['config' => $rows]);