fix(discord): clean migrated thread binding state (#89552) · openclaw/openclaw@038da08
SYU8384
·
2026-06-11
·
via Recent Commits to openclaw:main
File tree
extensions/discord/src/monitor
| Original file line number | Diff line number | Diff line change |
|---|
@@ -193,7 +193,7 @@ describe("Discord model picker preference migration", () => {
|
193 | 193 | expect(plan.pluginId).toBe("discord"); |
194 | 194 | expect(plan.namespace).toBe("thread-bindings"); |
195 | 195 | const entries = await plan.readEntries(); |
196 | | -expect(entries).toEqual([ |
| 196 | +expect(entries).toStrictEqual([ |
197 | 197 | { |
198 | 198 | key: "default:legacy-thread", |
199 | 199 | value: { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -195,7 +195,10 @@ export const detectDiscordLegacyStateMigrations: BundledChannelLegacyStateMigrat
|
195 | 195 | )) { |
196 | 196 | const normalized = normalizePersistedBinding(rawKey, rawEntry); |
197 | 197 | if (normalized) { |
198 | | -out.push({ key: toBindingRecordKey(normalized), value: normalized }); |
| 198 | +out.push({ |
| 199 | +key: toBindingRecordKey(normalized), |
| 200 | +value: normalized, |
| 201 | +}); |
199 | 202 | } |
200 | 203 | } |
201 | 204 | return out; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -215,23 +215,36 @@ export function normalizePersistedBinding(
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
218 | | -return { |
| 218 | +const record: ThreadBindingRecord = { |
219 | 219 | accountId, |
220 | 220 | channelId, |
221 | 221 | threadId, |
222 | 222 | targetKind, |
223 | 223 | targetSessionKey, |
224 | 224 | agentId, |
225 | | - label, |
226 | | - webhookId, |
227 | | - webhookToken, |
228 | 225 | boundBy, |
229 | 226 | boundAt, |
230 | 227 | lastActivityAt, |
231 | | -idleTimeoutMs: migratedIdleTimeoutMs, |
232 | | -maxAgeMs: migratedMaxAgeMs, |
233 | | - metadata, |
234 | 228 | }; |
| 229 | +if (label !== undefined) { |
| 230 | +record.label = label; |
| 231 | +} |
| 232 | +if (webhookId !== undefined) { |
| 233 | +record.webhookId = webhookId; |
| 234 | +} |
| 235 | +if (webhookToken !== undefined) { |
| 236 | +record.webhookToken = webhookToken; |
| 237 | +} |
| 238 | +if (migratedIdleTimeoutMs !== undefined) { |
| 239 | +record.idleTimeoutMs = migratedIdleTimeoutMs; |
| 240 | +} |
| 241 | +if (migratedMaxAgeMs !== undefined) { |
| 242 | +record.maxAgeMs = migratedMaxAgeMs; |
| 243 | +} |
| 244 | +if (metadata !== undefined) { |
| 245 | +record.metadata = metadata; |
| 246 | +} |
| 247 | +return record; |
235 | 248 | } |
236 | 249 | |
237 | 250 | export function normalizeThreadBindingDurationMs(raw: unknown, defaultsTo: number): number { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。