fix(gateway): only a real is_bot=True source is a bot peer; approval timeout reads the ctx source safely

Mock sources in the notice and approval suites carry a MagicMock is_bot; SessionSource.is_bot is a bool.
This commit is contained in:
Teknium committed 2026-11-04 21:01:10 -08:00
1 parent 04d7a37baf
commit 17c2065b2b
2 files changed
+4 -4

No files matched your search

+3 -3
View File
@@ -12,6 +12,6 @@ from typing import Any
def automatic_notices_allowed(source: Any) -> bool:
"""False when the message came from a known bot (``source.is_bot``: platform bot flag or the
adapter's ``bot_users`` opt-in)."""
return not bool(getattr(source, "is_bot", False))
"""False when the message came from a known bot (``SessionSource.is_bot``, a bool: the platform's
bot flag or the adapter's ``bot_users`` opt-in). Anything but a real ``True`` is not a known bot."""
return getattr(source, "is_bot", False) is not True
+1 -1
View File
@@ -67,7 +67,7 @@ async def _post_timeout_notice(
from gateway.bot_peer_notices import automatic_notices_allowed
adapter = ctx._status_adapter
if not automatic_notices_allowed(ctx.source):
if not automatic_notices_allowed(getattr(ctx, "source", None)):
return
notice = format_approval_timed_out_notice(timeout_s)
metadata = _interim_metadata(ctx._status_thread_metadata)