```
feat: 添加飞书用户模块和订阅功能支持 - 新增feishu_users模块用于处理飞书用户身份验证和权限管理 - 新增subscriptions模块用于处理订阅相关功能 - 新增personalization模块用于个性化服务 - 在alembic迁移配置中注册新的模型模块 - 在API路由器中添加feishu_users和subscriptions路由 - 实现事件调度服务的改进,包括错误处理和状态更新优化 - 添加飞书命令处理的权限检查机制 - 实现飞书应用票据事件处理 - 改进审计日志记录功能 ```
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
from typing import Any
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
from fastapi import APIRouter, Depends, Request
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.database import get_db
|
||||
from app.core.security import ApiPrincipal, require_api_key
|
||||
from app.application.feishu import FeishuCommandService, FeishuEventService
|
||||
from app.modules.feishu.constants import FeishuEventSource, FeishuPayloadKey, FeishuResponseKey
|
||||
from app.modules.feishu.event_verification import FeishuWebhookVerifier
|
||||
from app.modules.feishu.schemas import (
|
||||
FeishuCardMessage,
|
||||
FeishuCommandRequest,
|
||||
@@ -20,10 +19,11 @@ router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/webhook")
|
||||
def feishu_webhook(payload: dict[str, Any], db: Session = Depends(get_db)) -> dict:
|
||||
async def feishu_webhook(request: Request, db: Session = Depends(get_db)) -> dict:
|
||||
"""Handle Feishu webhook challenge and text command events."""
|
||||
|
||||
return FeishuEventService(db).handle_event(
|
||||
payload = FeishuWebhookVerifier().verify(await request.body(), request.headers)
|
||||
return FeishuEventService(db)._handle_verified_event(
|
||||
payload,
|
||||
source=FeishuEventSource.WEBHOOK,
|
||||
auto_reply=True,
|
||||
@@ -41,6 +41,7 @@ def send_text(
|
||||
receive_id=payload.receive_id,
|
||||
receive_id_type=payload.receive_id_type,
|
||||
actor=principal.actor,
|
||||
tenant_key=payload.tenant_key,
|
||||
)
|
||||
return {
|
||||
FeishuResponseKey.OK: result.get(FeishuPayloadKey.CODE) == 0,
|
||||
@@ -59,6 +60,7 @@ def send_card(
|
||||
receive_id=payload.receive_id,
|
||||
receive_id_type=payload.receive_id_type,
|
||||
actor=principal.actor,
|
||||
tenant_key=payload.tenant_key,
|
||||
)
|
||||
return {
|
||||
FeishuResponseKey.OK: result.get(FeishuPayloadKey.CODE) == 0,
|
||||
@@ -82,4 +84,5 @@ def preview_command(
|
||||
chat_id=payload.chat_id,
|
||||
actor=principal.actor,
|
||||
auto_reply=payload.auto_reply,
|
||||
tenant_key=payload.tenant_key,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user