fix(pairing): persist shortcut commands and avoid Feishu side effects
- AgentLoop._state_command now persists user message and assistant response for shortcut commands (e.g. /pairing) so WebUI history hydration after _turn_end no longer shows an empty chat. /new is excluded because it intentionally clears the session. - Feishu _on_message sends pairing codes for unauthorized DMs before any media side effects (reactions, downloads, transcription). Group chat unauthorized senders are still silently ignored early. - Update test_feishu_reply to assert the new DM pairing behavior.
This commit is contained in:
@@ -1712,6 +1712,18 @@ class FeishuChannel(BaseChannel):
|
||||
while len(self._processed_message_ids) > 1000:
|
||||
self._processed_message_ids.popitem(last=False)
|
||||
|
||||
# Early permission check — avoid side effects for unauthorized users.
|
||||
# Group chats are silently ignored; DMs get a pairing code.
|
||||
if not self.is_allowed(sender_id):
|
||||
if chat_type == "p2p":
|
||||
await self._handle_message(
|
||||
sender_id=sender_id,
|
||||
chat_id=sender_id,
|
||||
content="",
|
||||
is_dm=True,
|
||||
)
|
||||
return
|
||||
|
||||
# Add reaction (non-blocking — tracked background task)
|
||||
task = asyncio.create_task(
|
||||
self._add_reaction(message_id, self.config.react_emoji)
|
||||
|
||||
Reference in New Issue
Block a user