mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 19:33:43 +00:00
fix(routing): treat group/channel peer.kind as equivalent (land #31135 by @Sid-Qin)
Landed-from: #31135 Contributor: @Sid-Qin Co-authored-by: Sid <sidqin0410@gmail.com>
This commit is contained in:
@@ -262,12 +262,24 @@ function hasRolesConstraint(match: NormalizedBindingMatch): boolean {
|
||||
return Boolean(match.roles);
|
||||
}
|
||||
|
||||
function peerKindMatches(bindingKind: ChatType, scopeKind: ChatType): boolean {
|
||||
if (bindingKind === scopeKind) {
|
||||
return true;
|
||||
}
|
||||
const both = new Set([bindingKind, scopeKind]);
|
||||
return both.has("group") && both.has("channel");
|
||||
}
|
||||
|
||||
function matchesBindingScope(match: NormalizedBindingMatch, scope: BindingScope): boolean {
|
||||
if (match.peer.state === "invalid") {
|
||||
return false;
|
||||
}
|
||||
if (match.peer.state === "valid") {
|
||||
if (!scope.peer || scope.peer.kind !== match.peer.kind || scope.peer.id !== match.peer.id) {
|
||||
if (
|
||||
!scope.peer ||
|
||||
!peerKindMatches(match.peer.kind, scope.peer.kind) ||
|
||||
scope.peer.id !== match.peer.id
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user