mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 06:22:42 +00:00
refactor: split slack/discord/session maintenance helpers
This commit is contained in:
27
src/config/sessions/store-migrations.ts
Normal file
27
src/config/sessions/store-migrations.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { SessionEntry } from "./types.js";
|
||||
|
||||
export function applySessionStoreMigrations(store: Record<string, SessionEntry>): void {
|
||||
// Best-effort migration: message provider → channel naming.
|
||||
for (const entry of Object.values(store)) {
|
||||
if (!entry || typeof entry !== "object") {
|
||||
continue;
|
||||
}
|
||||
const rec = entry as unknown as Record<string, unknown>;
|
||||
if (typeof rec.channel !== "string" && typeof rec.provider === "string") {
|
||||
rec.channel = rec.provider;
|
||||
delete rec.provider;
|
||||
}
|
||||
if (typeof rec.lastChannel !== "string" && typeof rec.lastProvider === "string") {
|
||||
rec.lastChannel = rec.lastProvider;
|
||||
delete rec.lastProvider;
|
||||
}
|
||||
|
||||
// Best-effort migration: legacy `room` field → `groupChannel` (keep value, prune old key).
|
||||
if (typeof rec.groupChannel !== "string" && typeof rec.room === "string") {
|
||||
rec.groupChannel = rec.room;
|
||||
delete rec.room;
|
||||
} else if ("room" in rec) {
|
||||
delete rec.room;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user