Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions gateway/platforms/feishu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1647,8 +1647,14 @@ async def send(
last_response = None

try:
for chunk in chunks:
for i, chunk in enumerate(chunks):
msg_type, payload = self._build_outbound_payload(chunk)
logger.info(
"[Feishu] send_message: chat=%s reply_to=%s chunk=%d/%d "
"msg_type=%s payload_len=%d content_len=%d",
chat_id, reply_to, i + 1, len(chunks),
msg_type, len(payload), len(chunk),
)
try:
response = await self._feishu_send_with_retry(
chat_id=chat_id,
Expand Down Expand Up @@ -2723,7 +2729,7 @@ async def _process_inbound_message(
chat_type=self._resolve_source_chat_type(chat_info=chat_info, event_chat_type=chat_type),
user_id=sender_profile["user_id"],
user_name=sender_profile["user_name"],
thread_id=getattr(message, "thread_id", None) or None,
thread_id=getattr(message, "thread_id", None) or getattr(message, "root_id", None) or None,
user_id_alt=sender_profile["user_id_alt"],
)
normalized = MessageEvent(
Expand Down Expand Up @@ -3953,10 +3959,18 @@ def _response_error_result(

def _finalize_send_result(self, response: Any, default_message: str) -> SendResult:
if not self._response_succeeded(response):
return self._response_error_result(response, default_message=default_message)
result = self._response_error_result(response, default_message=default_message)
logger.warning(
"[Feishu] send failed: code=%s msg=%s",
getattr(response, "code", "unknown"),
getattr(response, "msg", default_message),
)
return result
msg_id = self._extract_response_field(response, "message_id")
logger.info("[Feishu] send succeeded: msg_id=%s", msg_id)
return SendResult(
success=True,
message_id=self._extract_response_field(response, "message_id"),
message_id=msg_id,
raw_response=response,
)

Expand Down
10 changes: 10 additions & 0 deletions gateway/stream_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,16 @@ async def _send_new_chunk(self, text: str, reply_to_id: Optional[str]) -> Option
return str(result.message_id)
else:
self._edit_supported = False
logger.warning(
"[StreamConsumer] Send failed (success=%s, msg_id=%s, error=%s) "
"chat=%s reply_to=%s text_len=%d",
result.success,
result.message_id,
getattr(result, "error", None),
self.chat_id,
reply_to_id,
len(text),
)
return reply_to_id
except Exception as e:
logger.error("Stream send chunk error: %s", e)
Expand Down