refactor(zalouser): reuse shared name matching helper
This commit is contained in:
@@ -22,6 +22,7 @@ import {
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
deleteAccountFromConfigSection,
|
||||
formatAllowFromLowercase,
|
||||
isDangerousNameMatchingEnabled,
|
||||
isNumericTargetId,
|
||||
migrateBaseNameToDefaultAccount,
|
||||
normalizeAccountId,
|
||||
@@ -37,11 +38,7 @@ import {
|
||||
type ResolvedZalouserAccount,
|
||||
} from "./accounts.js";
|
||||
import { ZalouserConfigSchema } from "./config-schema.js";
|
||||
import {
|
||||
buildZalouserGroupCandidates,
|
||||
findZalouserGroupEntry,
|
||||
isZalouserDangerousNameMatchingEnabled,
|
||||
} from "./group-policy.js";
|
||||
import { buildZalouserGroupCandidates, findZalouserGroupEntry } from "./group-policy.js";
|
||||
import { resolveZalouserReactionMessageIds } from "./message-sid.js";
|
||||
import { zalouserOnboardingAdapter } from "./onboarding.js";
|
||||
import { probeZalouser } from "./probe.js";
|
||||
@@ -220,7 +217,7 @@ function resolveZalouserGroupPolicyEntry(params: ChannelGroupContext) {
|
||||
groupId: params.groupId,
|
||||
groupChannel: params.groupChannel,
|
||||
includeWildcard: true,
|
||||
allowNameMatching: isZalouserDangerousNameMatchingEnabled(account.config),
|
||||
allowNameMatching: isDangerousNameMatchingEnabled(account.config),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,12 +17,6 @@ export function normalizeZalouserGroupSlug(raw?: string | null): string {
|
||||
.replace(/^-+|-+$/g, "");
|
||||
}
|
||||
|
||||
export function isZalouserDangerousNameMatchingEnabled(params: {
|
||||
dangerouslyAllowNameMatching?: boolean;
|
||||
}): boolean {
|
||||
return params.dangerouslyAllowNameMatching === true;
|
||||
}
|
||||
|
||||
export function buildZalouserGroupCandidates(params: {
|
||||
groupId?: string | null;
|
||||
groupChannel?: string | null;
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
createScopedPairingAccess,
|
||||
createReplyPrefixOptions,
|
||||
evaluateGroupRouteAccessForPolicy,
|
||||
isDangerousNameMatchingEnabled,
|
||||
issuePairingChallenge,
|
||||
resolveOutboundMediaUrls,
|
||||
mergeAllowlist,
|
||||
@@ -33,7 +34,6 @@ import {
|
||||
import {
|
||||
buildZalouserGroupCandidates,
|
||||
findZalouserGroupEntry,
|
||||
isZalouserDangerousNameMatchingEnabled,
|
||||
isZalouserGroupEntryAllowed,
|
||||
} from "./group-policy.js";
|
||||
import { formatZalouserMessageSidFull, resolveZalouserMessageSid } from "./message-sid.js";
|
||||
@@ -319,7 +319,7 @@ async function processMessage(
|
||||
});
|
||||
|
||||
const groups = account.config.groups ?? {};
|
||||
const allowNameMatching = isZalouserDangerousNameMatchingEnabled(account.config);
|
||||
const allowNameMatching = isDangerousNameMatchingEnabled(account.config);
|
||||
if (isGroup) {
|
||||
const groupEntry = findZalouserGroupEntry(
|
||||
groups,
|
||||
|
||||
@@ -42,6 +42,7 @@ export type { ChannelPlugin } from "../channels/plugins/types.plugin.js";
|
||||
export { createReplyPrefixOptions } from "../channels/reply-prefix.js";
|
||||
export { createTypingCallbacks } from "../channels/typing.js";
|
||||
export type { OpenClawConfig } from "../config/config.js";
|
||||
export { isDangerousNameMatchingEnabled } from "../config/dangerous-name-matching.js";
|
||||
export {
|
||||
resolveDefaultGroupPolicy,
|
||||
resolveOpenProviderRuntimeGroupPolicy,
|
||||
|
||||
Reference in New Issue
Block a user