```
feat(feishu): 添加飞书入站事件inbox和混合数据库协调功能 - 实现飞书入站事件持久化inbox机制,支持状态管理、租约锁定和重试退避 - 添加混合数据库基线协调工具,确保平台PostgreSQL结构安全对齐 - 增加运行组件心跳检测和readiness就绪检查机制 - 实现app_ticket事件的安全轮换和验证处理 - 添加生产环境运行编排和fail-closed安全机制 - 支持webhook快速确认和长连接独立进程处理 - 完善个人数据擦除时的待处理事件清理功能 ```
This commit is contained in:
@@ -65,19 +65,44 @@ FINANCE_COMMAND_PREFIXES = ("资金需求", "未来30天资金需求", "项目
|
||||
def _parse_content_text(content: Any) -> str:
|
||||
"""Extract plain command text from a Feishu message content payload."""
|
||||
|
||||
if isinstance(content, dict):
|
||||
return str(
|
||||
content.get(FeishuPayloadKey.TEXT) or content.get(FeishuPayloadKey.CONTENT) or ""
|
||||
)
|
||||
if not isinstance(content, str):
|
||||
return ""
|
||||
return _structured_content_text(content)
|
||||
try:
|
||||
data = json.loads(content)
|
||||
except json.JSONDecodeError:
|
||||
return content
|
||||
if isinstance(data, dict):
|
||||
return str(data.get(FeishuPayloadKey.TEXT) or data.get(FeishuPayloadKey.CONTENT) or "")
|
||||
return content
|
||||
return _structured_content_text(data)
|
||||
|
||||
|
||||
def _structured_content_text(value: Any) -> str:
|
||||
"""Flatten Feishu text and rich-post content without stringifying metadata."""
|
||||
|
||||
if isinstance(value, str):
|
||||
return value
|
||||
if isinstance(value, list):
|
||||
separator = "\n" if any(isinstance(item, list) for item in value) else ""
|
||||
return separator.join(
|
||||
text
|
||||
for item in value
|
||||
if (text := _structured_content_text(item))
|
||||
)
|
||||
if not isinstance(value, dict):
|
||||
return ""
|
||||
|
||||
tag = str(value.get("tag") or "").strip().lower()
|
||||
if tag == "br":
|
||||
return "\n"
|
||||
if tag == "at":
|
||||
# Authorization uses the event's structured mentions, not display text.
|
||||
return " "
|
||||
|
||||
text_value = value.get(FeishuPayloadKey.TEXT)
|
||||
if isinstance(text_value, str):
|
||||
return text_value
|
||||
if FeishuPayloadKey.CONTENT in value:
|
||||
return _structured_content_text(value.get(FeishuPayloadKey.CONTENT))
|
||||
title = value.get("title")
|
||||
return title if isinstance(title, str) else ""
|
||||
|
||||
|
||||
def _clean_command_text(text: str) -> str:
|
||||
|
||||
Reference in New Issue
Block a user