fix: sender fallback for command auth (#755) (thanks @juanpablodlc)

This commit is contained in:
Peter Steinberger
2026-01-12 06:28:53 +00:00
parent 20d606c4c4
commit 46a6d79784
4 changed files with 49 additions and 9 deletions

View File

@@ -0,0 +1,30 @@
import { describe, expect, it } from "vitest";
import type { ClawdbotConfig } from "../config/config.js";
import { resolveCommandAuthorization } from "./command-auth.js";
import type { MsgContext } from "./templating.js";
describe("resolveCommandAuthorization", () => {
it("falls back from empty SenderId to SenderE164", () => {
const cfg = {
whatsapp: { allowFrom: ["+123"] },
} as ClawdbotConfig;
const ctx = {
Provider: "whatsapp",
Surface: "whatsapp",
From: "whatsapp:+999",
SenderId: "",
SenderE164: "+123",
} as MsgContext;
const auth = resolveCommandAuthorization({
ctx,
cfg,
commandAuthorized: true,
});
expect(auth.senderId).toBe("+123");
expect(auth.isAuthorizedSender).toBe(true);
});
});