mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-20 00:22:31 +00:00
simplify(pairing): unify allow_list lookup in BaseChannel.is_allowed()
Merge the three-branch dict lookup (allow_from key check, allowFrom fallback, getattr) into a single `or` chain. Same semantics, less branching.
This commit is contained in:
parent
ada11b38c4
commit
cab4bdbf33
@ -184,12 +184,9 @@ class BaseChannel(ABC):
|
|||||||
def is_allowed(self, sender_id: str) -> bool:
|
def is_allowed(self, sender_id: str) -> bool:
|
||||||
"""Check sender permission: star > allowlist > pairing store > deny."""
|
"""Check sender permission: star > allowlist > pairing store > deny."""
|
||||||
if isinstance(self.config, dict):
|
if isinstance(self.config, dict):
|
||||||
if "allow_from" in self.config:
|
allow_list = self.config.get("allow_from") or self.config.get("allowFrom") or []
|
||||||
allow_list = self.config.get("allow_from") or []
|
|
||||||
else:
|
else:
|
||||||
allow_list = self.config.get("allowFrom", []) or []
|
allow_list = getattr(self.config, "allow_from", None) or []
|
||||||
else:
|
|
||||||
allow_list = getattr(self.config, "allow_from", []) or []
|
|
||||||
if "*" in allow_list:
|
if "*" in allow_list:
|
||||||
return True
|
return True
|
||||||
# allowFrom entries are opaque tokens — must match exactly.
|
# allowFrom entries are opaque tokens — must match exactly.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user