fix: preserve empty dict allow_from handling

Keep dict-backed channel configs compatible with both allow_from and allowFrom without losing empty-list semantics, and add focused regression coverage for the allow-list boundary.

Made-with: Cursor
This commit is contained in:
Xubin Ren
2026-04-15 01:26:51 +08:00
committed by Xubin Ren
parent 73cf9a220b
commit 1f33df1ea6
4 changed files with 43 additions and 3 deletions
+4 -1
View File
@@ -117,7 +117,10 @@ class BaseChannel(ABC):
def is_allowed(self, sender_id: str) -> bool:
"""Check if *sender_id* is permitted. Empty list → deny all; ``"*"`` → allow all."""
if isinstance(self.config, dict):
allow_list = self.config.get("allow_from") or self.config.get("allowFrom") or []
if "allow_from" in self.config:
allow_list = self.config.get("allow_from")
else:
allow_list = self.config.get("allowFrom", [])
else:
allow_list = getattr(self.config, "allow_from", [])
if not allow_list: