fix(commands): honor channel-native command auth

This commit is contained in:
Ayaan Zaidi
2026-04-28 21:56:38 +05:30
parent bdfb408ce6
commit 7b91f06384
2 changed files with 28 additions and 1 deletions

View File

@@ -53,6 +53,30 @@ describe("senderIsOwner only reflects explicit owner authorization", () => {
expect(auth.isAuthorizedSender).toBe(true);
});
it("keeps channel-validated native group commands authorized without owner status", () => {
const cfg = {
channels: { telegram: {} },
} as OpenClawConfig;
const ctx = {
Provider: "telegram",
Surface: "telegram",
ChatType: "group",
From: "telegram:group:-100123",
SenderId: "200482621",
CommandSource: "native",
} as MsgContext;
const auth = resolveCommandAuthorization({
ctx,
cfg,
commandAuthorized: true,
});
expect(auth.senderIsOwner).toBe(false);
expect(auth.isAuthorizedSender).toBe(true);
});
it("senderIsOwner is false when ownerAllowFrom is configured and sender does not match", () => {
const cfg = {
channels: { discord: {} },

View File

@@ -450,7 +450,10 @@ function resolveCommandSenderAuthorization(params: {
!params.providerResolutionError && (commandsAllowAll || Boolean(matchedCommandsAllowFrom))
);
}
return params.commandAuthorized && params.isOwnerForCommands;
if (params.commandAuthorized) {
return true;
}
return params.isOwnerForCommands;
}
function isConversationLikeIdentity(value: string): boolean {