





















@@ -14,9 +14,12 @@ import { afterEach, describe, expect, it } from "vitest";
1414import { resolveTelegramBotInfoCachePath } from "./bot-info-cache.js";
1515import { resolveTelegramMessageCachePath } from "./message-cache.js";
1616import {
17+buildTelegramMessageDispatchAccountReplayKey,
1718resolveTelegramMessageDispatchLegacyPath,
18-TELEGRAM_MESSAGE_DISPATCH_DEDUPE_MAX_ENTRIES,
19+TELEGRAM_MESSAGE_DISPATCH_DEDUPE_NAMESPACE,
1920TELEGRAM_MESSAGE_DISPATCH_DEDUPE_NAMESPACE_PREFIX,
21+TELEGRAM_MESSAGE_DISPATCH_DEDUPE_STATE_PLUGIN_ID,
22+TELEGRAM_MESSAGE_DISPATCH_DEDUPE_STATE_MAX_ENTRIES,
2023TELEGRAM_MESSAGE_DISPATCH_DEDUPE_TTL_MS,
2124} from "./message-dispatch-dedupe.js";
2225import { detectTelegramLegacyStateMigrations } from "./state-migrations.js";
@@ -369,7 +372,7 @@ describe("telegram state migrations", () => {
369372} as OpenClawConfig;
370373const plans = await detectTelegramLegacyStateMigrations({ cfg, env });
371374const dispatchNamespace = resolvePersistentDedupePluginStateNamespace({
372-namespace: "ops",
375+namespace: TELEGRAM_MESSAGE_DISPATCH_DEDUPE_NAMESPACE,
373376namespacePrefix: TELEGRAM_MESSAGE_DISPATCH_DEDUPE_NAMESPACE_PREFIX,
374377});
375378@@ -396,6 +399,7 @@ describe("telegram state migrations", () => {
396399});
397400expect(byLabel.get("Telegram message dispatch dedupe")).toMatchObject({
398401kind: "plugin-state-import",
402+pluginId: TELEGRAM_MESSAGE_DISPATCH_DEDUPE_STATE_PLUGIN_ID,
399403sourcePath: dispatchPath,
400404namespace: dispatchNamespace,
401405});
@@ -407,7 +411,10 @@ describe("telegram state migrations", () => {
407411{
408412key: expect.stringMatching(/^k\.[a-f0-9]{32}$/),
409413value: {
410-key: JSON.stringify(["message", "7", 42]),
414+key: buildTelegramMessageDispatchAccountReplayKey({
415+accountId: "ops",
416+key: JSON.stringify(["message", "7", 42]),
417+}),
411418seenAt: now,
412419},
413420},
@@ -437,7 +444,7 @@ describe("telegram state migrations", () => {
437444const now = Date.now();
438445const replayKey = JSON.stringify(["message", "7", 42]);
439446const dispatchNamespace = resolvePersistentDedupePluginStateNamespace({
440-namespace: "ops",
447+namespace: TELEGRAM_MESSAGE_DISPATCH_DEDUPE_NAMESPACE,
441448namespacePrefix: TELEGRAM_MESSAGE_DISPATCH_DEDUPE_NAMESPACE_PREFIX,
442449});
443450try {
@@ -476,6 +483,7 @@ describe("telegram state migrations", () => {
476483477484expect(plan).toMatchObject({
478485kind: "plugin-state-import",
486+pluginId: TELEGRAM_MESSAGE_DISPATCH_DEDUPE_STATE_PLUGIN_ID,
479487namespace: dispatchNamespace,
480488});
481489if (!plan || plan.kind !== "plugin-state-import") {
@@ -486,18 +494,24 @@ describe("telegram state migrations", () => {
486494{
487495key: expect.stringMatching(/^k\.[a-f0-9]{32}$/),
488496value: {
489-key: replayKey,
497+key: buildTelegramMessageDispatchAccountReplayKey({
498+accountId: "ops",
499+key: replayKey,
500+}),
490501seenAt: now,
491502},
492503},
493504]);
494505495-const targetStore = createPluginStateSyncKeyedStoreForTests("telegram", {
496-namespace: dispatchNamespace,
497-maxEntries: TELEGRAM_MESSAGE_DISPATCH_DEDUPE_MAX_ENTRIES,
498-defaultTtlMs: TELEGRAM_MESSAGE_DISPATCH_DEDUPE_TTL_MS,
499- env,
500-});
506+const targetStore = createPluginStateSyncKeyedStoreForTests(
507+TELEGRAM_MESSAGE_DISPATCH_DEDUPE_STATE_PLUGIN_ID,
508+{
509+namespace: dispatchNamespace,
510+maxEntries: TELEGRAM_MESSAGE_DISPATCH_DEDUPE_STATE_MAX_ENTRIES,
511+defaultTtlMs: TELEGRAM_MESSAGE_DISPATCH_DEDUPE_TTL_MS,
512+ env,
513+},
514+);
501515for (const entry of entries) {
502516targetStore.register(
503517entry.key,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。