feat(onebot): migrate musicSignUrl from per-UIN to global config

musicSignUrl is a deployment-wide signing-service endpoint (same for every
account), so it belongs in the global config/snowluma.json next to rkey, not in
per-UIN onebot_<uin>.json.

- GlobalSettings gains musicSignUrl (http(s)-validated, '' = built-in default);
  consumption switches to globalSettings.musicSignUrl and hot-reloads via
  applyGlobalSettings.
- One-shot copy-up at boot (migrateGlobalSettings, called first in main()):
  lifts the first VALID legacy value from any config/onebot*.json into the
  global store. Idempotent via a key-PRESENCE guard, so an intentional
  clear-to-'' is never reverted by a stale legacy value.
- Remove musicSignUrl from per-UIN OneBotConfig (type + parse/serialize).

Phase 2 of the global-settings split. (WebUI form follows in Phase 3.)
This commit is contained in:
DrSmoothl committed 2026-06-28 21:38:32 +08:00
1 parent 659970077a
commit ea1c5ff9eb
8 files changed
+185 -23

No files matched your search

-5
View File
@@ -61,7 +61,6 @@ export function makeDefaultOneBotConfig(): OneBotConfig {
}],
wsClients: [],
},
musicSignUrl: '',
statusCommand: makeDefaultStatusCommand(),
notifications: { channelIds: [] },
};
@@ -115,7 +114,6 @@ function toJsonObject(config: OneBotConfig): JsonObject {
wsServers: nets.wsServers.map(wsServerToJson),
wsClients: nets.wsClients.map(wsClientToJson),
},
musicSignUrl: config.musicSignUrl ?? '',
statusCommand: {
enabled: config.statusCommand.enabled,
swallow: config.statusCommand.swallow,
@@ -179,12 +177,10 @@ function wsClientToJson(n: WsClientNetwork): JsonObject {
function fromJson(sources: JsonObject[], freshInstall: boolean): OneBotConfig {
let legacyFormat: MessageFormat | undefined;
let legacyReport: boolean | undefined;
let musicSignUrl = '';
for (const src of sources) {
const mf = parseMessageFormat(src.messageFormat);
if (mf) legacyFormat = mf;
if (typeof src.reportSelfMessage === 'boolean') legacyReport = src.reportSelfMessage;
if (typeof src.musicSignUrl === 'string') musicSignUrl = src.musicSignUrl;
}
const inheritedFormat: MessageFormat = legacyFormat ?? 'array';
const inheritedReport: boolean = legacyReport ?? false;
@@ -208,7 +204,6 @@ function fromJson(sources: JsonObject[], freshInstall: boolean): OneBotConfig {
const networks: OneBotNetworks = { httpServers, httpClients, wsServers, wsClients };
return {
networks,
musicSignUrl,
statusCommand: parseStatusCommand(sources),
notifications: parseNotifications(sources),
};