fix: normalize WhatsApp targets for groups and E.164 (#631) (thanks @imfing)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user