@@ -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 ,
1718 resolveTelegramMessageDispatchLegacyPath ,
18- TELEGRAM_MESSAGE_DISPATCH_DEDUPE_MAX_ENTRIES ,
19+ TELEGRAM_MESSAGE_DISPATCH_DEDUPE_NAMESPACE ,
1920 TELEGRAM_MESSAGE_DISPATCH_DEDUPE_NAMESPACE_PREFIX ,
21+ TELEGRAM_MESSAGE_DISPATCH_DEDUPE_STATE_PLUGIN_ID ,
22+ TELEGRAM_MESSAGE_DISPATCH_DEDUPE_STATE_MAX_ENTRIES ,
2023 TELEGRAM_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 ;
370373 const plans = await detectTelegramLegacyStateMigrations ( { cfg, env } ) ;
371374 const dispatchNamespace = resolvePersistentDedupePluginStateNamespace ( {
372- namespace : "ops" ,
375+ namespace : TELEGRAM_MESSAGE_DISPATCH_DEDUPE_NAMESPACE ,
373376 namespacePrefix : TELEGRAM_MESSAGE_DISPATCH_DEDUPE_NAMESPACE_PREFIX ,
374377 } ) ;
375378
@@ -396,6 +399,7 @@ describe("telegram state migrations", () => {
396399 } ) ;
397400 expect ( byLabel . get ( "Telegram message dispatch dedupe" ) ) . toMatchObject ( {
398401 kind : "plugin-state-import" ,
402+ pluginId : TELEGRAM_MESSAGE_DISPATCH_DEDUPE_STATE_PLUGIN_ID ,
399403 sourcePath : dispatchPath ,
400404 namespace : dispatchNamespace ,
401405 } ) ;
@@ -407,7 +411,10 @@ describe("telegram state migrations", () => {
407411 {
408412 key : expect . stringMatching ( / ^ k \. [ a - f 0 - 9 ] { 32 } $ / ) ,
409413 value : {
410- key : JSON . stringify ( [ "message" , "7" , 42 ] ) ,
414+ key : buildTelegramMessageDispatchAccountReplayKey ( {
415+ accountId : "ops" ,
416+ key : JSON . stringify ( [ "message" , "7" , 42 ] ) ,
417+ } ) ,
411418 seenAt : now ,
412419 } ,
413420 } ,
@@ -437,7 +444,7 @@ describe("telegram state migrations", () => {
437444 const now = Date . now ( ) ;
438445 const replayKey = JSON . stringify ( [ "message" , "7" , 42 ] ) ;
439446 const dispatchNamespace = resolvePersistentDedupePluginStateNamespace ( {
440- namespace : "ops" ,
447+ namespace : TELEGRAM_MESSAGE_DISPATCH_DEDUPE_NAMESPACE ,
441448 namespacePrefix : TELEGRAM_MESSAGE_DISPATCH_DEDUPE_NAMESPACE_PREFIX ,
442449 } ) ;
443450 try {
@@ -476,6 +483,7 @@ describe("telegram state migrations", () => {
476483
477484 expect ( plan ) . toMatchObject ( {
478485 kind : "plugin-state-import" ,
486+ pluginId : TELEGRAM_MESSAGE_DISPATCH_DEDUPE_STATE_PLUGIN_ID ,
479487 namespace : dispatchNamespace ,
480488 } ) ;
481489 if ( ! plan || plan . kind !== "plugin-state-import" ) {
@@ -486,18 +494,24 @@ describe("telegram state migrations", () => {
486494 {
487495 key : expect . stringMatching ( / ^ k \. [ a - f 0 - 9 ] { 32 } $ / ) ,
488496 value : {
489- key : replayKey ,
497+ key : buildTelegramMessageDispatchAccountReplayKey ( {
498+ accountId : "ops" ,
499+ key : replayKey ,
500+ } ) ,
490501 seenAt : now ,
491502 } ,
492503 } ,
493504 ] ) ;
494505
495- 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+ ) ;
501515 for ( const entry of entries ) {
502516 targetStore . register (
503517 entry . key ,
0 commit comments