refactor(onebot): move rkey fallback from per-UIN to a global config store
The rkey fallback endpoint is deployment infra (one self-hosted server serves
all accounts; fallback rkeys are fungible), so it doesn't belong in per-UIN
onebot_<uin>.json. Introduce config/snowluma.json — a generic home for small
all-accounts SnowLuma settings — and move rkey.fallbackServers there.
- New onebot/global-config.ts: load/save/normalize with section-merge + atomic
write; http(s)+host URL validation; default [] (off). Lives in onebot (not
core) because the onebot manager constructs instances and must not depend on
core.
- OneBotInstance takes globalSettings; manager loads it on session start and
exposes reloadGlobalSettings() to hot-push edits to every live instance via
applyGlobalSettings → RKeyCache.setFallbackServers.
- Remove rkey from per-UIN OneBotConfig + the WebUI per-UIN round-trip (never
released, so no migration). Register snowluma.json in the backup allowlist.
Reworks the per-UIN rkey from 12b0190. Phase 1 of the global-settings split.
This commit is contained in:
12 files changed
+227
-78
No files matched your search
@@ -65,16 +65,5 @@ export function normalizeOneBotConfig(raw: unknown): OneBotConfig {
|
||||
musicSignUrl: typeof cfg.musicSignUrl === 'string' ? cfg.musicSignUrl : undefined,
|
||||
statusCommand: normalizeStatusCommand(cfg.statusCommand),
|
||||
notifications: normalizeNotifications(cfg.notifications),
|
||||
rkey: normalizeRkey(cfg.rkey),
|
||||
};
|
||||
}
|
||||
|
||||
/** Preserve `rkey.fallbackServers` verbatim so a hand-edited value isn't wiped
|
||||
* when the operator saves an unrelated change from the WebUI (no form yet). */
|
||||
function normalizeRkey(raw: unknown): { fallbackServers: string[] } {
|
||||
const obj = (raw ?? {}) as Record<string, unknown>;
|
||||
const servers = Array.isArray(obj.fallbackServers)
|
||||
? obj.fallbackServers.filter((s): s is string => typeof s === 'string')
|
||||
: [];
|
||||
return { fallbackServers: servers };
|
||||
}
|
||||
@@ -111,9 +111,6 @@ export interface OneBotConfig {
|
||||
statusCommand: StatusCommandConfig;
|
||||
/** Per-account opt-in to global notification channels (by channel id). */
|
||||
notifications?: { channelIds: string[] };
|
||||
/** Opt-in remote rkey fallback servers. No dedicated form yet — preserved
|
||||
* verbatim across load/save so a hand-edited value survives WebUI writes. */
|
||||
rkey?: { fallbackServers: string[] };
|
||||
}
|
||||
|
||||
// ─── Notifications (account up/down webhooks) ───────────────────────────────
|
||||
|
||||
Reference in new issue
Block a user