mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 03:51:25 +00:00
fix: harden outbound mirroring normalization
This commit is contained in:
@@ -137,6 +137,34 @@ describe("gateway send mirroring", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("lowercases provided session keys for mirroring", async () => {
|
||||
mocks.deliverOutboundPayloads.mockResolvedValue([{ messageId: "m-lower", channel: "slack" }]);
|
||||
|
||||
const respond = vi.fn();
|
||||
await sendHandlers.send({
|
||||
params: {
|
||||
to: "channel:C1",
|
||||
message: "hi",
|
||||
channel: "slack",
|
||||
idempotencyKey: "idem-lower",
|
||||
sessionKey: "agent:main:slack:channel:C123",
|
||||
},
|
||||
respond,
|
||||
context: makeContext(),
|
||||
req: { type: "req", id: "1", method: "send" },
|
||||
client: null,
|
||||
isWebchatConnect: () => false,
|
||||
});
|
||||
|
||||
expect(mocks.deliverOutboundPayloads).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
mirror: expect.objectContaining({
|
||||
sessionKey: "agent:main:slack:channel:c123",
|
||||
}),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("derives a target session key when none is provided", async () => {
|
||||
mocks.deliverOutboundPayloads.mockResolvedValue([{ messageId: "m3", channel: "slack" }]);
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ export const sendHandlers: GatewayRequestHandlers = {
|
||||
);
|
||||
const providedSessionKey =
|
||||
typeof request.sessionKey === "string" && request.sessionKey.trim()
|
||||
? request.sessionKey.trim()
|
||||
? request.sessionKey.trim().toLowerCase()
|
||||
: undefined;
|
||||
const derivedAgentId = resolveSessionAgentId({ config: cfg });
|
||||
// If callers omit sessionKey, derive a target session key from the outbound route.
|
||||
|
||||
Reference in New Issue
Block a user