Revert "fix(feishu): streaming card and tool hint respect reply_to_message in…"
This reverts commit 651b6b933f.
This commit is contained in:
+14
-23
@@ -1135,25 +1135,6 @@ class FeishuChannel(BaseChannel):
|
||||
logger.debug("Feishu: error fetching parent message {}: {}", message_id, e)
|
||||
return None
|
||||
|
||||
def _thread_reply_target(self, meta: dict) -> str | None:
|
||||
"""Pick the inbound message_id to reply to with reply_in_thread=True.
|
||||
|
||||
Returns the message_id when the response must travel through the
|
||||
Reply API (continuation of an existing topic, or user opted in via
|
||||
``reply_to_message=True``); returns None to signal a plain send.
|
||||
Used by streaming-card / fallback / tool-hint paths so they honor
|
||||
the same gating as the regular send() path and don't unilaterally
|
||||
spawn new topics in groups when ``reply_to_message`` is off.
|
||||
"""
|
||||
if meta.get("chat_type", "group") != "group":
|
||||
return None
|
||||
msg_id = meta.get("message_id")
|
||||
if not msg_id:
|
||||
return None
|
||||
if meta.get("thread_id") or self.config.reply_to_message:
|
||||
return msg_id
|
||||
return None
|
||||
|
||||
def _reply_message_sync(self, parent_message_id: str, msg_type: str, content: str, *, reply_in_thread: bool = False) -> bool:
|
||||
"""Reply to an existing Feishu message using the Reply API (synchronous).
|
||||
|
||||
@@ -1428,7 +1409,11 @@ class FeishuChannel(BaseChannel):
|
||||
{"config": {"wide_screen_mode": True}, "elements": chunk},
|
||||
ensure_ascii=False,
|
||||
)
|
||||
fallback_msg_id = self._thread_reply_target(meta)
|
||||
# Fallback: reply via the Reply API for group chats.
|
||||
# Target message_id — the Feishu API keeps the reply in
|
||||
# the same topic automatically.
|
||||
_f_msg = meta.get("message_id")
|
||||
fallback_msg_id = _f_msg if meta.get("chat_type", "group") == "group" else None
|
||||
if fallback_msg_id:
|
||||
await loop.run_in_executor(
|
||||
None, lambda: self._reply_message_sync(
|
||||
@@ -1453,7 +1438,12 @@ class FeishuChannel(BaseChannel):
|
||||
|
||||
now = time.monotonic()
|
||||
if buf.card_id is None:
|
||||
reply_msg_id = self._thread_reply_target(meta)
|
||||
# Send the streaming card as a reply for group chats so it
|
||||
# lands inside the originating topic/thread. Always target
|
||||
# message_id (the actual inbound message) — the Feishu Reply
|
||||
# API keeps the response in the same topic automatically.
|
||||
is_group = meta.get("chat_type", "group") == "group"
|
||||
reply_msg_id = meta.get("message_id") if is_group else None
|
||||
card_id = await loop.run_in_executor(
|
||||
None,
|
||||
self._create_streaming_card_sync,
|
||||
@@ -1508,8 +1498,9 @@ class FeishuChannel(BaseChannel):
|
||||
]},
|
||||
ensure_ascii=False,
|
||||
)
|
||||
_th_msg_id = self._thread_reply_target(msg.metadata)
|
||||
if _th_msg_id:
|
||||
_th_msg_id = msg.metadata.get("message_id")
|
||||
_th_chat_type = msg.metadata.get("chat_type", "group")
|
||||
if _th_msg_id and _th_chat_type == "group":
|
||||
await loop.run_in_executor(
|
||||
None, lambda: self._reply_message_sync(
|
||||
_th_msg_id, "interactive", card,
|
||||
|
||||
Reference in New Issue
Block a user