mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-28 09:33:38 +00:00
fix(reply): avoid bundled channel load in dedupe (#93104)
This commit is contained in:
@@ -5,7 +5,6 @@ import {
|
||||
} from "@openclaw/normalization-core/string-coerce";
|
||||
import { isMessagingToolDuplicate } from "../../agents/embedded-agent-helpers.js";
|
||||
import type { MessagingToolSend } from "../../agents/embedded-agent-messaging.types.js";
|
||||
import { getChannelPlugin } from "../../channels/plugins/index.js";
|
||||
import { getLoadedChannelPluginForRead } from "../../channels/plugins/registry-loaded-read.js";
|
||||
import { normalizeAnyChannelId } from "../../channels/registry.js";
|
||||
import type { OpenClawConfig } from "../../config/types.openclaw.js";
|
||||
@@ -189,7 +188,8 @@ function targetsMatchForDedupe(params: {
|
||||
targetKey: string;
|
||||
targetThreadId?: string;
|
||||
}): boolean {
|
||||
const pluginMatch = getChannelPlugin(params.provider)?.outbound?.targetsMatchForReplySuppression;
|
||||
const pluginMatch = getLoadedChannelPluginForRead(params.provider)?.outbound
|
||||
?.targetsMatchForReplySuppression;
|
||||
if (pluginMatch) {
|
||||
return pluginMatch({
|
||||
originTarget: params.originTarget,
|
||||
@@ -214,7 +214,8 @@ function resolveOriginThreadIdForPayload(params: {
|
||||
return originThreadId;
|
||||
}
|
||||
const replyToId = normalizeThreadIdForComparison(params.replyToId);
|
||||
const resolveReplyTransport = getChannelPlugin(params.provider)?.threading?.resolveReplyTransport;
|
||||
const resolveReplyTransport = getLoadedChannelPluginForRead(params.provider)?.threading
|
||||
?.resolveReplyTransport;
|
||||
if (!replyToId || !params.config || !resolveReplyTransport) {
|
||||
return originThreadId;
|
||||
}
|
||||
@@ -325,7 +326,7 @@ export function getMatchingMessagingToolReplyTargets(params: {
|
||||
// that encode the thread/topic inside the target string carry their own
|
||||
// matcher and must still run it.
|
||||
const hasPluginThreadMatcher = Boolean(
|
||||
getChannelPlugin(provider)?.outbound?.targetsMatchForReplySuppression,
|
||||
getLoadedChannelPluginForRead(provider)?.outbound?.targetsMatchForReplySuppression,
|
||||
);
|
||||
if (!hasPluginThreadMatcher && (originRoute.threadId != null || targetRoute.threadId != null)) {
|
||||
return false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Tests reply payload helper behavior and delivery metadata.
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resetPluginRuntimeStateForTest, setActivePluginRegistry } from "../../plugins/runtime.js";
|
||||
import { createOutboundTestPlugin, createTestRegistry } from "../../test-utils/channel-plugins.js";
|
||||
import { getReplyPayloadMetadata, setReplyPayloadMetadata } from "../reply-payload.js";
|
||||
@@ -26,17 +26,6 @@ function targetsMatchTelegramReplySuppression(params: {
|
||||
);
|
||||
}
|
||||
|
||||
vi.mock("../../channels/plugins/bundled.js", () => ({
|
||||
getBundledChannelPlugin: (channel: string) =>
|
||||
channel === "telegram"
|
||||
? {
|
||||
outbound: {
|
||||
targetsMatchForReplySuppression: targetsMatchTelegramReplySuppression,
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
}));
|
||||
|
||||
describe("filterMessagingToolMediaDuplicates", () => {
|
||||
it("strips mediaUrl when it matches sentMediaUrls", () => {
|
||||
const result = filterMessagingToolMediaDuplicates({
|
||||
@@ -262,7 +251,7 @@ describe("shouldDedupeMessagingToolRepliesForRoute", () => {
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("matches telegram replies even when the active plugin registry omits telegram", () => {
|
||||
it("uses generic route matching when the active plugin registry omits telegram", () => {
|
||||
resetPluginRuntimeStateForTest();
|
||||
setActivePluginRegistry(createTestRegistry([]));
|
||||
|
||||
@@ -274,7 +263,7 @@ describe("shouldDedupeMessagingToolRepliesForRoute", () => {
|
||||
{ tool: "message", provider: "telegram", to: "-100123", threadId: "77" },
|
||||
],
|
||||
}),
|
||||
).toBe(true);
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user