fix(gateway): treat webchat last as whatsapp
This commit is contained in:
@@ -300,7 +300,8 @@ describe("gateway server", () => {
|
|||||||
await server.close();
|
await server.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("agent forces no-deliver when last-channel is webchat", async () => {
|
test("agent ignores webchat last-channel for routing", async () => {
|
||||||
|
testAllowFrom = ["+1555"];
|
||||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdis-gw-"));
|
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdis-gw-"));
|
||||||
testSessionStorePath = path.join(dir, "sessions.json");
|
testSessionStorePath = path.join(dir, "sessions.json");
|
||||||
await fs.writeFile(
|
await fs.writeFile(
|
||||||
@@ -311,7 +312,7 @@ describe("gateway server", () => {
|
|||||||
sessionId: "sess-main-webchat",
|
sessionId: "sess-main-webchat",
|
||||||
updatedAt: Date.now(),
|
updatedAt: Date.now(),
|
||||||
lastChannel: "webchat",
|
lastChannel: "webchat",
|
||||||
lastTo: "ignored",
|
lastTo: "+1555",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
@@ -351,8 +352,9 @@ describe("gateway server", () => {
|
|||||||
const spy = vi.mocked(agentCommand);
|
const spy = vi.mocked(agentCommand);
|
||||||
expect(spy).toHaveBeenCalled();
|
expect(spy).toHaveBeenCalled();
|
||||||
const call = spy.mock.calls.at(-1)?.[0] as Record<string, unknown>;
|
const call = spy.mock.calls.at(-1)?.[0] as Record<string, unknown>;
|
||||||
expect(call.provider).toBe("webchat");
|
expect(call.provider).toBe("whatsapp");
|
||||||
expect(call.deliver).toBe(false);
|
expect(call.to).toBe("+1555");
|
||||||
|
expect(call.deliver).toBe(true);
|
||||||
expect(call.bestEffortDeliver).toBe(true);
|
expect(call.bestEffortDeliver).toBe(true);
|
||||||
expect(call.sessionId).toBe("sess-main-webchat");
|
expect(call.sessionId).toBe("sess-main-webchat");
|
||||||
|
|
||||||
|
|||||||
@@ -1174,7 +1174,11 @@ export async function startGatewayServer(
|
|||||||
|
|
||||||
const resolvedChannel = (() => {
|
const resolvedChannel = (() => {
|
||||||
if (requestedChannel === "last") {
|
if (requestedChannel === "last") {
|
||||||
return lastChannel ?? "whatsapp";
|
// WebChat is not a deliverable surface. Treat it as "unset" for routing,
|
||||||
|
// so VoiceWake and CLI callers don't get stuck with deliver=false.
|
||||||
|
return lastChannel && lastChannel !== "webchat"
|
||||||
|
? lastChannel
|
||||||
|
: "whatsapp";
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
requestedChannel === "whatsapp" ||
|
requestedChannel === "whatsapp" ||
|
||||||
@@ -1183,7 +1187,9 @@ export async function startGatewayServer(
|
|||||||
) {
|
) {
|
||||||
return requestedChannel;
|
return requestedChannel;
|
||||||
}
|
}
|
||||||
return lastChannel ?? "whatsapp";
|
return lastChannel && lastChannel !== "webchat"
|
||||||
|
? lastChannel
|
||||||
|
: "whatsapp";
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const resolvedTo = (() => {
|
const resolvedTo = (() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user