mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-04 16:14:09 +00:00
refactor(telegram): persist plugin state in sqlite
Move Telegram plugin-local state from JSON sidecars into plugin-state SQLite. Keep legacy JSON handling in startup and doctor migration plans, with runtime state now reading and writing SQLite directly. Stabilize the channel Vitest lane by cleaning up typing timers and isolating that lane.
This commit is contained in:
committed by
GitHub
parent
b9fe0894a6
commit
930b371a2f
@@ -211,6 +211,9 @@ describe("ensureConfigReady", () => {
|
||||
["Discord model picker preferences", "discord/model-picker-preferences.json"],
|
||||
["Feishu dedupe sidecar", "feishu/dedup/default.json"],
|
||||
["Telegram bot info cache", "telegram/bot-info-default.json"],
|
||||
["Telegram update offset", "telegram/update-offset-default.json"],
|
||||
["Telegram sticker cache", "telegram/sticker-cache.json"],
|
||||
["Telegram thread bindings", "telegram/thread-bindings-default.json"],
|
||||
["Telegram pairing allowFrom", "credentials/telegram-allowFrom.json"],
|
||||
["WhatsApp root auth", "credentials/creds.json"],
|
||||
])("runs doctor flow for bundled channel legacy state: %s", async (_label, relativePath) => {
|
||||
|
||||
@@ -57,6 +57,15 @@ function isLegacyWhatsAppAuthFile(name: string): boolean {
|
||||
return name.endsWith(".json") && /^(app-state-sync|session|sender-key|pre-key)-/.test(name);
|
||||
}
|
||||
|
||||
function isLegacyTelegramStateFile(name: string): boolean {
|
||||
return (
|
||||
(name.startsWith("bot-info-") && name.endsWith(".json")) ||
|
||||
(name.startsWith("update-offset-") && name.endsWith(".json")) ||
|
||||
name === "sticker-cache.json" ||
|
||||
(name.startsWith("thread-bindings-") && name.endsWith(".json"))
|
||||
);
|
||||
}
|
||||
|
||||
function hasBundledChannelLegacyStateMigrationInputs(stateDir: string, oauthDir: string): boolean {
|
||||
if (fileOrDirExists(path.join(stateDir, "discord", "model-picker-preferences.json"))) {
|
||||
return true;
|
||||
@@ -66,10 +75,7 @@ function hasBundledChannelLegacyStateMigrationInputs(stateDir: string, oauthDir:
|
||||
}
|
||||
if (
|
||||
fileOrDirExists(path.join(oauthDir, "telegram-allowFrom.json")) ||
|
||||
dirHasFile(
|
||||
path.join(stateDir, "telegram"),
|
||||
(name) => name.startsWith("bot-info-") && name.endsWith(".json"),
|
||||
)
|
||||
dirHasFile(path.join(stateDir, "telegram"), isLegacyTelegramStateFile)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user