mirror of https://github.com/openclaw/openclaw.git
Discord: implement role allowlist with OR logic in preflight
This commit is contained in:
parent
8ff89ba14c
commit
4c0ce46ac3
|
|
@ -181,6 +181,20 @@ export function resolveDiscordOwnerAllowFrom(params: {
|
|||
return [match.matchKey];
|
||||
}
|
||||
|
||||
export function resolveDiscordRoleAllowed(params: {
|
||||
allowList?: Array<string | number>;
|
||||
memberRoleIds: string[];
|
||||
}) {
|
||||
const allowList = normalizeDiscordAllowList(params.allowList, ["role:"]);
|
||||
if (!allowList) {
|
||||
return true;
|
||||
}
|
||||
if (allowList.allowAll) {
|
||||
return true;
|
||||
}
|
||||
return params.memberRoleIds.some((roleId) => allowList.ids.has(roleId));
|
||||
}
|
||||
|
||||
export function resolveDiscordCommandAuthorized(params: {
|
||||
isDirectMessage: boolean;
|
||||
allowFrom?: Array<string | number>;
|
||||
|
|
|
|||
Loading…
Reference in New Issue