fix: dedupe inbound messages across providers

This commit is contained in:
Peter Steinberger
2026-01-11 00:12:17 +01:00
parent bd2002010c
commit 7c76561569
18 changed files with 353 additions and 53 deletions

View File

@@ -4,6 +4,7 @@ import { getReplyFromConfig } from "../reply.js";
import type { MsgContext } from "../templating.js";
import type { GetReplyOptions, ReplyPayload } from "../types.js";
import { tryFastAbortFromMessage } from "./abort.js";
import { shouldSkipDuplicateInbound } from "./inbound-dedupe.js";
import type { ReplyDispatcher, ReplyDispatchKind } from "./reply-dispatcher.js";
import { isRoutableChannel, routeReply } from "./route-reply.js";
@@ -21,6 +22,10 @@ export async function dispatchReplyFromConfig(params: {
}): Promise<DispatchFromConfigResult> {
const { ctx, cfg, dispatcher } = params;
if (shouldSkipDuplicateInbound(ctx)) {
return { queuedFinal: false, counts: dispatcher.getQueuedCounts() };
}
// Check if we should route replies to originating channel instead of dispatcher.
// Only route when the originating channel is DIFFERENT from the current surface.
// This handles cross-provider routing (e.g., message from Telegram being processed