mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-13 19:36:05 +00:00
fix(discord): clean migrated thread binding state (#89552)
* fix(discord): clean migrated thread binding state * fix(discord): omit undefined thread binding fields --------- Co-authored-by: Hex <hex@openclaw.ai>
This commit is contained in:
@@ -193,7 +193,7 @@ describe("Discord model picker preference migration", () => {
|
||||
expect(plan.pluginId).toBe("discord");
|
||||
expect(plan.namespace).toBe("thread-bindings");
|
||||
const entries = await plan.readEntries();
|
||||
expect(entries).toEqual([
|
||||
expect(entries).toStrictEqual([
|
||||
{
|
||||
key: "default:legacy-thread",
|
||||
value: {
|
||||
|
||||
@@ -195,7 +195,10 @@ export const detectDiscordLegacyStateMigrations: BundledChannelLegacyStateMigrat
|
||||
)) {
|
||||
const normalized = normalizePersistedBinding(rawKey, rawEntry);
|
||||
if (normalized) {
|
||||
out.push({ key: toBindingRecordKey(normalized), value: normalized });
|
||||
out.push({
|
||||
key: toBindingRecordKey(normalized),
|
||||
value: normalized,
|
||||
});
|
||||
}
|
||||
}
|
||||
return out;
|
||||
|
||||
@@ -215,23 +215,36 @@ export function normalizePersistedBinding(
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
const record: ThreadBindingRecord = {
|
||||
accountId,
|
||||
channelId,
|
||||
threadId,
|
||||
targetKind,
|
||||
targetSessionKey,
|
||||
agentId,
|
||||
label,
|
||||
webhookId,
|
||||
webhookToken,
|
||||
boundBy,
|
||||
boundAt,
|
||||
lastActivityAt,
|
||||
idleTimeoutMs: migratedIdleTimeoutMs,
|
||||
maxAgeMs: migratedMaxAgeMs,
|
||||
metadata,
|
||||
};
|
||||
if (label !== undefined) {
|
||||
record.label = label;
|
||||
}
|
||||
if (webhookId !== undefined) {
|
||||
record.webhookId = webhookId;
|
||||
}
|
||||
if (webhookToken !== undefined) {
|
||||
record.webhookToken = webhookToken;
|
||||
}
|
||||
if (migratedIdleTimeoutMs !== undefined) {
|
||||
record.idleTimeoutMs = migratedIdleTimeoutMs;
|
||||
}
|
||||
if (migratedMaxAgeMs !== undefined) {
|
||||
record.maxAgeMs = migratedMaxAgeMs;
|
||||
}
|
||||
if (metadata !== undefined) {
|
||||
record.metadata = metadata;
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
export function normalizeThreadBindingDurationMs(raw: unknown, defaultsTo: number): number {
|
||||
|
||||
Reference in New Issue
Block a user