mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-29 10:02:04 +00:00
refactor: dedupe channel and gateway surfaces
This commit is contained in:
@@ -61,13 +61,12 @@ describe("describeIMessageEchoDropLog", () => {
|
||||
|
||||
describe("resolveIMessageInboundDecision command auth", () => {
|
||||
const cfg = {} as OpenClawConfig;
|
||||
|
||||
it("does not auto-authorize DM commands in open mode without allowlists", () => {
|
||||
const decision = resolveIMessageInboundDecision({
|
||||
const resolveDmCommandDecision = (params: { messageId: number; storeAllowFrom: string[] }) =>
|
||||
resolveIMessageInboundDecision({
|
||||
cfg,
|
||||
accountId: "default",
|
||||
message: {
|
||||
id: 100,
|
||||
id: params.messageId,
|
||||
sender: "+15555550123",
|
||||
text: "/status",
|
||||
is_from_me: false,
|
||||
@@ -80,13 +79,19 @@ describe("resolveIMessageInboundDecision command auth", () => {
|
||||
groupAllowFrom: [],
|
||||
groupPolicy: "open",
|
||||
dmPolicy: "open",
|
||||
storeAllowFrom: [],
|
||||
storeAllowFrom: params.storeAllowFrom,
|
||||
historyLimit: 0,
|
||||
groupHistories: new Map(),
|
||||
echoCache: undefined,
|
||||
logVerbose: undefined,
|
||||
});
|
||||
|
||||
it("does not auto-authorize DM commands in open mode without allowlists", () => {
|
||||
const decision = resolveDmCommandDecision({
|
||||
messageId: 100,
|
||||
storeAllowFrom: [],
|
||||
});
|
||||
|
||||
expect(decision.kind).toBe("dispatch");
|
||||
if (decision.kind !== "dispatch") {
|
||||
return;
|
||||
@@ -95,28 +100,9 @@ describe("resolveIMessageInboundDecision command auth", () => {
|
||||
});
|
||||
|
||||
it("authorizes DM commands for senders in pairing-store allowlist", () => {
|
||||
const decision = resolveIMessageInboundDecision({
|
||||
cfg,
|
||||
accountId: "default",
|
||||
message: {
|
||||
id: 101,
|
||||
sender: "+15555550123",
|
||||
text: "/status",
|
||||
is_from_me: false,
|
||||
is_group: false,
|
||||
},
|
||||
opts: undefined,
|
||||
messageText: "/status",
|
||||
bodyText: "/status",
|
||||
allowFrom: [],
|
||||
groupAllowFrom: [],
|
||||
groupPolicy: "open",
|
||||
dmPolicy: "open",
|
||||
const decision = resolveDmCommandDecision({
|
||||
messageId: 101,
|
||||
storeAllowFrom: ["+15555550123"],
|
||||
historyLimit: 0,
|
||||
groupHistories: new Map(),
|
||||
echoCache: undefined,
|
||||
logVerbose: undefined,
|
||||
});
|
||||
|
||||
expect(decision.kind).toBe("dispatch");
|
||||
|
||||
Reference in New Issue
Block a user