mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:50:43 +00:00
fix(commands): honor channel-native command auth
This commit is contained in:
@@ -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: {} },
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user