feat: 添加飞书用户模块和订阅功能支持 - 新增feishu_users模块用于处理飞书用户身份验证和权限管理 - 新增subscriptions模块用于处理订阅相关功能 - 新增personalization模块用于个性化服务 - 在alembic迁移配置中注册新的模型模块 - 在API路由器中添加feishu_users和subscriptions路由 - 实现事件调度服务的改进,包括错误处理和状态更新优化 - 添加飞书命令处理的权限检查机制 - 实现飞书应用票据事件处理 - 改进审计日志记录功能 ```
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
from typing import Any
|
|
|
|
from app.core.config import get_settings
|
|
from app.modules.feishu.service import FeishuService
|
|
|
|
|
|
def send_text_if_configured(
|
|
feishu: FeishuService,
|
|
chat_id: str | None,
|
|
text: str,
|
|
actor: str,
|
|
*,
|
|
record_audit: bool = True,
|
|
) -> dict[str, Any] | None:
|
|
"""Send a text reply only when Feishu credentials are configured."""
|
|
|
|
settings = get_settings()
|
|
if not (settings.feishu_app_id and settings.feishu_app_secret):
|
|
return None
|
|
return feishu.send_text(
|
|
text,
|
|
receive_id=chat_id,
|
|
actor=actor,
|
|
record_audit=record_audit,
|
|
)
|
|
|
|
|
|
def send_card_if_configured(
|
|
feishu: FeishuService,
|
|
chat_id: str | None,
|
|
title: str,
|
|
lines: list[str],
|
|
actor: str,
|
|
) -> dict[str, Any] | None:
|
|
"""Send a basic card only when Feishu credentials are configured."""
|
|
|
|
settings = get_settings()
|
|
if not (settings.feishu_app_id and settings.feishu_app_secret):
|
|
return None
|
|
card = FeishuService.build_basic_card(title, lines)
|
|
return feishu.send_card(card, receive_id=chat_id, actor=actor)
|