feat(webui): configure login history backfill
Expose the per-account login history backfill switch in General settings and keep missing or legacy configuration disabled by default. Document that changes apply on the next login, historical messages are stored locally without event replay or read-state changes, and fixed safety limits govern roster scanning, selected sessions, page size, request spacing, and retries. Add WebUI normalization coverage so the optional setting survives save and restore without silently inheriting an enabled value. Refs #280.
This commit is contained in:
5 files changed
+51
No files matched your search
@@ -86,6 +86,12 @@ SNOWLUMA_ACCEPT_PRIVACY=1
|
||||
|
||||
</details>
|
||||
|
||||
## 可选:登录时补齐云端历史
|
||||
|
||||
WebUI 的账号“通用设置”可开启登录历史补齐,默认关闭,并在下次登录或重启后生效。该功能只把缺失的 QQ 云端漫游消息静默写入 SnowLuma 本地历史库,不重放 OneBot 事件,也不改变 QQ 已读状态。
|
||||
|
||||
花名册预热完成后会等待 30 秒,且进程内一次只为一个账号执行自动补齐。每次登录最多扫描 100 个群和 100 位好友,优先续补本地已知缺口,每类最多处理 3 个会话;每个会话最多读取 20 条消息,自动请求之间至少间隔 2 秒,失败后本次登录不重试。
|
||||
|
||||
## 日志与存储管理
|
||||
|
||||
WebUI 的“系统设置 → 存储管理”可查看受管数据占用、调整日志策略,并清理日志、非活动传输临时文件或离线账号的消息、媒体和表情回应数据库。清理范围固定,不包含配置、凭据或其他文件。
|
||||
|
||||
@@ -22,6 +22,24 @@ export function GeneralSettingsTab({ config, onChange }: GeneralSettingsTabProps
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="flex items-start justify-between gap-3 rounded-lg border bg-card/40 p-4">
|
||||
<div className="min-w-0">
|
||||
<Label>登录时补齐云端历史记录</Label>
|
||||
<p className="mt-1 text-xs leading-relaxed text-muted-foreground">
|
||||
下次账号登录或重启后生效。只静默写入本地消息库,不重放历史事件,也不改变 QQ 已读状态。
|
||||
每次最多处理 3 个群和 3 个好友、每个会话 20 条,自动请求至少间隔 2 秒。
|
||||
</p>
|
||||
</div>
|
||||
<ToggleSwitch
|
||||
value={config.historySync.enabled}
|
||||
onChange={(enabled) => onChange({
|
||||
...config,
|
||||
historySync: { enabled },
|
||||
})}
|
||||
ariaLabel="登录时补齐云端历史记录"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-4 rounded-lg border bg-card/40 p-4">
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
|
||||
@@ -63,6 +63,14 @@ export function normalizeOneBotConfig(raw: unknown): OneBotConfig {
|
||||
wsClients: list(nets.wsClients) as unknown as OneBotConfig['networks']['wsClients'],
|
||||
},
|
||||
statusCommand: normalizeStatusCommand(cfg.statusCommand),
|
||||
historySync: {
|
||||
enabled: (
|
||||
typeof cfg.historySync === 'object'
|
||||
&& cfg.historySync !== null
|
||||
&& !Array.isArray(cfg.historySync)
|
||||
&& (cfg.historySync as Record<string, unknown>).enabled === true
|
||||
),
|
||||
},
|
||||
notifications: normalizeNotifications(cfg.notifications),
|
||||
};
|
||||
}
|
||||
@@ -108,9 +108,14 @@ export interface StatusCommandConfig {
|
||||
trigger: string;
|
||||
}
|
||||
|
||||
export interface HistorySyncConfig {
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
export interface OneBotConfig {
|
||||
networks: OneBotNetworks;
|
||||
statusCommand: StatusCommandConfig;
|
||||
historySync: HistorySyncConfig;
|
||||
/** Per-account opt-in to global notification channels (by channel id). */
|
||||
notifications?: { channelIds: string[] };
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { normalizeOneBotConfig } from '../src/lib/onebot-config';
|
||||
|
||||
describe('normalizeOneBotConfig history sync', () => {
|
||||
it('defaults older payloads to disabled', () => {
|
||||
expect(normalizeOneBotConfig({}).historySync).toEqual({ enabled: false });
|
||||
});
|
||||
|
||||
it('preserves an explicit per-account opt-in', () => {
|
||||
expect(normalizeOneBotConfig({
|
||||
historySync: { enabled: true },
|
||||
}).historySync).toEqual({ enabled: true });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user