refactor: split slack/discord/session maintenance helpers

This commit is contained in:
Peter Steinberger
2026-03-02 23:07:12 +00:00
parent 3043e68dfa
commit 7eda632324
16 changed files with 983 additions and 749 deletions

View 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;
}
}
}