feat(onebot): opt-in remote rkey fallback server (#156)
On accounts where the native OIDB 0x9067_202 rkey fetch persistently returns
nothing, every image was served as a bare multimedia.nt.qq.com.cn URL the CDN
rejects with invalid rkey — SnowLuma had no fallback, unlike NapCat.
Add config.rkey.fallbackServers (default []: OFF; no third-party server is
contacted unless the operator configures one). When the native fetch leaves the
cache without a usable image rkey, each configured HTTP endpoint is tried in
turn for { group_rkey, private_rkey, expired_time } (NapCat rkey-server format;
an OneBot { retcode, data } wrapper is also accepted), populating the group/
private image rkey types. Values keep any leading &rkey=/?rkey= since
resolveImageUrl strips before re-appending.
WebUI has no form yet but round-trips rkey.fallbackServers verbatim so a hand-
edited value survives an unrelated config save. Part B of #156 (cooldown is A).
This commit is contained in:
8 files changed
+265
-7
No files matched your search
@@ -65,5 +65,16 @@ 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,6 +111,9 @@ 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