fix: normalize WhatsApp targets for groups and E.164 (#631) (thanks @imfing)

This commit is contained in:
Xin
2026-01-10 00:07:09 +00:00
committed by Peter Steinberger
parent a6822e1210
commit f0700e9778
8 changed files with 181 additions and 13 deletions

View File

@@ -12,6 +12,15 @@ describe("resolveOutboundTarget", () => {
expect(res).toEqual({ ok: true, to: "+1555" });
});
it("normalizes whatsapp allowFrom fallback targets", () => {
const res = resolveOutboundTarget({
provider: "whatsapp",
to: "",
allowFrom: ["whatsapp:(555) 123-4567"],
});
expect(res).toEqual({ ok: true, to: "+5551234567" });
});
it("normalizes whatsapp target when provided", () => {
const res = resolveOutboundTarget({
provider: "whatsapp",
@@ -21,6 +30,14 @@ describe("resolveOutboundTarget", () => {
expect(res.to).toBe("+5551234567");
});
it("keeps whatsapp group targets", () => {
const res = resolveOutboundTarget({
provider: "whatsapp",
to: "120363401234567890@g.us",
});
expect(res).toEqual({ ok: true, to: "120363401234567890@g.us" });
});
it("rejects telegram with missing target", () => {
const res = resolveOutboundTarget({ provider: "telegram", to: " " });
expect(res.ok).toBe(false);