fix(whatsapp): normalize user JIDs for group allowlists (#838)
Thanks @peschee. Co-authored-by: Peter Siska <63866+peschee@users.noreply.github.com>
This commit is contained in:
@@ -30,7 +30,7 @@ describe("resolveCommandAuthorization", () => {
|
||||
|
||||
it("falls back from whitespace SenderId to SenderE164", () => {
|
||||
const cfg = {
|
||||
whatsapp: { allowFrom: ["+123"] },
|
||||
channels: { whatsapp: { allowFrom: ["+123"] } },
|
||||
} as ClawdbotConfig;
|
||||
|
||||
const ctx = {
|
||||
@@ -53,7 +53,7 @@ describe("resolveCommandAuthorization", () => {
|
||||
|
||||
it("falls back to From when SenderId and SenderE164 are whitespace", () => {
|
||||
const cfg = {
|
||||
whatsapp: { allowFrom: ["+999"] },
|
||||
channels: { whatsapp: { allowFrom: ["+999"] } },
|
||||
} as ClawdbotConfig;
|
||||
|
||||
const ctx = {
|
||||
@@ -73,4 +73,27 @@ describe("resolveCommandAuthorization", () => {
|
||||
expect(auth.senderId).toBe("+999");
|
||||
expect(auth.isAuthorizedSender).toBe(true);
|
||||
});
|
||||
|
||||
it("falls back from un-normalizable SenderId to SenderE164", () => {
|
||||
const cfg = {
|
||||
channels: { whatsapp: { allowFrom: ["+123"] } },
|
||||
} as ClawdbotConfig;
|
||||
|
||||
const ctx = {
|
||||
Provider: "whatsapp",
|
||||
Surface: "whatsapp",
|
||||
From: "whatsapp:+999",
|
||||
SenderId: "wat",
|
||||
SenderE164: "+123",
|
||||
} as MsgContext;
|
||||
|
||||
const auth = resolveCommandAuthorization({
|
||||
ctx,
|
||||
cfg,
|
||||
commandAuthorized: true,
|
||||
});
|
||||
|
||||
expect(auth.senderId).toBe("+123");
|
||||
expect(auth.isAuthorizedSender).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user