mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
perf: use normalized ClickClack group lookups
This commit is contained in:
@@ -117,16 +117,12 @@ describe("resolveClickClackGroupPolicy", () => {
|
||||
expect(result.requireMention).toBe(false);
|
||||
});
|
||||
|
||||
it("trims channel id keys", () => {
|
||||
// Edge case: leading/trailing whitespace is trimmed during resolution
|
||||
// but our test passes raw channelId as is; exact match requires
|
||||
// the trimmed key. The resolver does not trim; the caller must trim.
|
||||
// Validating that untrimmed exact match works.
|
||||
it("trims inbound channel ids before lookup", () => {
|
||||
const result = resolveClickClackGroupPolicy({
|
||||
account: {
|
||||
groups: { "chn_exact ": { requireMention: true } },
|
||||
groups: { chn_exact: { requireMention: true } },
|
||||
},
|
||||
channelId: "chn_exact ",
|
||||
channelId: " chn_exact ",
|
||||
});
|
||||
expect(result.requireMention).toBe(true);
|
||||
});
|
||||
|
||||
@@ -35,9 +35,7 @@ export function resolveClickClackGroupPolicy(params: {
|
||||
};
|
||||
const wildcard = account.groups?.["*"];
|
||||
const channelKey = channelId?.trim();
|
||||
const exact = channelKey
|
||||
? Object.entries(account.groups ?? {}).find(([key]) => key.trim() === channelKey)?.[1]
|
||||
: undefined;
|
||||
const exact = channelKey ? account.groups?.[channelKey] : undefined;
|
||||
// Channel rules are partial overrides. Resolve each field independently so
|
||||
// an exact channel rule can inherit unspecified fields from the wildcard
|
||||
// rule before falling back to the account-level policy.
|
||||
|
||||
Reference in New Issue
Block a user