mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-29 18:12:52 +00:00
fix: normalize shared approval target channels
This commit is contained in:
@@ -40,6 +40,27 @@ describe("isChannelExecApprovalTargetRecipient", () => {
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("normalizes the requested channel id before matching targets", () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
approvals: {
|
||||
exec: {
|
||||
enabled: true,
|
||||
mode: "targets",
|
||||
targets: [{ channel: "matrix", to: "user:@owner:example.org" }],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
expect(
|
||||
isChannelExecApprovalTargetRecipient({
|
||||
cfg,
|
||||
senderId: "@owner:example.org",
|
||||
channel: " Matrix ",
|
||||
matchTarget: ({ target, normalizedSenderId }) => target.to === `user:${normalizedSenderId}`,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("createChannelExecApprovalProfile", () => {
|
||||
|
||||
@@ -49,6 +49,7 @@ export function isChannelExecApprovalTargetRecipient(params: {
|
||||
}): boolean {
|
||||
const normalizeSenderId = params.normalizeSenderId ?? defaultNormalizeSenderId;
|
||||
const normalizedSenderId = params.senderId ? normalizeSenderId(params.senderId) : undefined;
|
||||
const normalizedChannel = params.channel.trim().toLowerCase();
|
||||
if (!normalizedSenderId || !isApprovalTargetsMode(params.cfg)) {
|
||||
return false;
|
||||
}
|
||||
@@ -58,7 +59,7 @@ export function isChannelExecApprovalTargetRecipient(params: {
|
||||
}
|
||||
const normalizedAccountId = params.accountId ? normalizeAccountId(params.accountId) : undefined;
|
||||
return targets.some((target) => {
|
||||
if (target.channel?.trim().toLowerCase() !== params.channel) {
|
||||
if (target.channel?.trim().toLowerCase() !== normalizedChannel) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user