feat: 添加飞书用户模块和订阅功能支持 - 新增feishu_users模块用于处理飞书用户身份验证和权限管理 - 新增subscriptions模块用于处理订阅相关功能 - 新增personalization模块用于个性化服务 - 在alembic迁移配置中注册新的模型模块 - 在API路由器中添加feishu_users和subscriptions路由 - 实现事件调度服务的改进,包括错误处理和状态更新优化 - 添加飞书命令处理的权限检查机制 - 实现飞书应用票据事件处理 - 改进审计日志记录功能 ```
54 lines
1.4 KiB
Python
54 lines
1.4 KiB
Python
from typing import Any
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from app.core.constants import ActorValue
|
|
from app.modules.feishu.constants import FeishuReceiveIdType
|
|
|
|
|
|
class FeishuTextMessage(BaseModel):
|
|
receive_id: str | None = Field(
|
|
default=None,
|
|
description="chat_id or open_id depending on type.",
|
|
)
|
|
receive_id_type: str = FeishuReceiveIdType.CHAT_ID
|
|
tenant_key: str | None = Field(default=None, max_length=128)
|
|
text: str
|
|
|
|
|
|
class FeishuCardMessage(BaseModel):
|
|
receive_id: str | None = None
|
|
receive_id_type: str = FeishuReceiveIdType.CHAT_ID
|
|
tenant_key: str | None = Field(default=None, max_length=128)
|
|
card: dict[str, Any]
|
|
|
|
|
|
class FeishuWebhookEvent(BaseModel):
|
|
type: str | None = None
|
|
challenge: str | None = None
|
|
token: str | None = None
|
|
schema_: str | None = Field(default=None, alias="schema")
|
|
header: dict[str, Any] | None = None
|
|
event: dict[str, Any] | None = None
|
|
|
|
|
|
class FeishuSendResult(BaseModel):
|
|
ok: bool
|
|
provider_response: dict[str, Any]
|
|
|
|
|
|
class FeishuCommandRequest(BaseModel):
|
|
text: str
|
|
chat_id: str | None = None
|
|
tenant_key: str | None = Field(default=None, max_length=128)
|
|
actor: str = ActorValue.API
|
|
auto_reply: bool = False
|
|
|
|
|
|
class FeishuCommandResult(BaseModel):
|
|
command: str
|
|
reply_type: str
|
|
title: str
|
|
content: str
|
|
provider_response: dict[str, Any] | None = None
|