mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 10:27:38 +00:00
refactor(zalo): split monitor access and webhook logic
This commit is contained in:
@@ -9,6 +9,25 @@ export function formatAllowFromLowercase(params: {
|
||||
.map((entry) => entry.toLowerCase());
|
||||
}
|
||||
|
||||
export function isNormalizedSenderAllowed(params: {
|
||||
senderId: string | number;
|
||||
allowFrom: Array<string | number>;
|
||||
stripPrefixRe?: RegExp;
|
||||
}): boolean {
|
||||
const normalizedAllow = formatAllowFromLowercase({
|
||||
allowFrom: params.allowFrom,
|
||||
stripPrefixRe: params.stripPrefixRe,
|
||||
});
|
||||
if (normalizedAllow.length === 0) {
|
||||
return false;
|
||||
}
|
||||
if (normalizedAllow.includes("*")) {
|
||||
return true;
|
||||
}
|
||||
const sender = String(params.senderId).trim().toLowerCase();
|
||||
return normalizedAllow.includes(sender);
|
||||
}
|
||||
|
||||
type ParsedChatAllowTarget =
|
||||
| { kind: "chat_id"; chatId: number }
|
||||
| { kind: "chat_guid"; chatGuid: string }
|
||||
|
||||
Reference in New Issue
Block a user