refactor: centralize WhatsApp target normalization

This commit is contained in:
Peter Steinberger
2026-01-10 02:39:50 +01:00
parent 8f8caa8d89
commit 9cd2662a86
9 changed files with 191 additions and 130 deletions

View File

@@ -96,6 +96,21 @@ describe("resolveHeartbeatDeliveryTarget", () => {
});
});
it("normalizes explicit WhatsApp targets when allowFrom is '*'", () => {
const cfg: ClawdbotConfig = {
agents: {
defaults: {
heartbeat: { target: "whatsapp", to: "whatsapp:(555) 123" },
},
},
whatsapp: { allowFrom: ["*"] },
};
expect(resolveHeartbeatDeliveryTarget({ cfg, entry: baseEntry })).toEqual({
provider: "whatsapp",
to: "+555123",
});
});
it("skips when last route is webchat", () => {
const cfg: ClawdbotConfig = {};
const entry = {