























@@ -48,18 +48,19 @@ describe("resolveCommandAuthorization", () => {
4848setActivePluginRegistry(createTestRegistry(plugins));
4949}
505051-function resolveWhatsAppAuthorization(params: {
51+function resolveTestChannelAuthorization(params: {
5252from: string;
5353senderId?: string;
5454senderE164?: string;
5555allowFrom: string[];
5656}) {
57+registerAllowFromPlugins(createAllowFromPlugin("mobilechat", () => params.allowFrom));
5758const cfg = {
58-channels: { whatsapp: { allowFrom: params.allowFrom } },
59+channels: { mobilechat: { allowFrom: params.allowFrom } },
5960} as OpenClawConfig;
6061const ctx = {
61-Provider: "whatsapp",
62-Surface: "whatsapp",
62+Provider: "mobilechat",
63+Surface: "mobilechat",
6364From: params.from,
6465SenderId: params.senderId,
6566SenderE164: params.senderE164,
@@ -74,46 +75,46 @@ describe("resolveCommandAuthorization", () => {
7475it.each([
7576{
7677name: "falls back from empty SenderId to SenderE164",
77-from: "whatsapp:+999",
78+from: "mobilechat:+999",
7879senderId: "",
7980senderE164: "+123",
8081allowFrom: ["+123"],
8182expectedSenderId: "+123",
8283},
8384{
8485name: "falls back from whitespace SenderId to SenderE164",
85-from: "whatsapp:+999",
86+from: "mobilechat:+999",
8687senderId: " ",
8788senderE164: "+123",
8889allowFrom: ["+123"],
8990expectedSenderId: "+123",
9091},
9192{
9293name: "falls back to From when SenderId and SenderE164 are whitespace",
93-from: "whatsapp:+999",
94+from: "+999",
9495senderId: " ",
9596senderE164: " ",
9697allowFrom: ["+999"],
9798expectedSenderId: "+999",
9899},
99100{
100101name: "falls back from un-normalizable SenderId to SenderE164",
101-from: "whatsapp:+999",
102+from: "mobilechat:+999",
102103senderId: "wat",
103104senderE164: "+123",
104105allowFrom: ["+123"],
105106expectedSenderId: "+123",
106107},
107108{
108109name: "prefers SenderE164 when SenderId does not match allowFrom",
109-from: "whatsapp:120363401234567890@g.us",
110-senderId: "123@lid",
110+from: "mobilechat:group:room-1",
111+senderId: "opaque-user",
111112senderE164: "+41796666864",
112113allowFrom: ["+41796666864"],
113114expectedSenderId: "+41796666864",
114115},
115116])("$name", ({ from, senderId, senderE164, allowFrom, expectedSenderId }) => {
116-const auth = resolveWhatsAppAuthorization({
117+const auth = resolveTestChannelAuthorization({
117118 from,
118119 senderId,
119120 senderE164,
@@ -559,7 +560,7 @@ describe("resolveCommandAuthorization", () => {
559560const cfg = {
560561commands: {
561562allowFrom: {
562-"*": ["120363411111111111@g.us"],
563+"*": ["demo:group:room-1"],
563564},
564565},
565566} as OpenClawConfig;
@@ -568,7 +569,7 @@ describe("resolveCommandAuthorization", () => {
568569ctx: {
569570Provider: "whatsapp",
570571Surface: "whatsapp",
571-From: "120363411111111111@g.us",
572+From: "demo:group:room-1",
572573SenderId: " ",
573574SenderE164: " ",
574575} as MsgContext,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。