feat: 重构处理历史与通知留痕追踪
This commit is contained in:
@@ -2,7 +2,7 @@ from django.shortcuts import get_object_or_404, redirect, render
|
||||
|
||||
from agent_core.orchestrator import run_agent
|
||||
from agent_core.results import AgentResult
|
||||
from apps.audit.services import create_audit_log
|
||||
from apps.audit.services import create_audit_log, create_notification_record
|
||||
from apps.documents.models import SubmissionBatch, UploadedDocument
|
||||
from apps.scenarios.services import get_scenario
|
||||
|
||||
@@ -70,6 +70,7 @@ def detail(request, conversation_id: str):
|
||||
conversation_id=conversation.conversation_id,
|
||||
product_name=conversation.product_name,
|
||||
)
|
||||
_persist_notification_records(result)
|
||||
active_node = "risk"
|
||||
|
||||
return render(
|
||||
@@ -89,3 +90,23 @@ def detail(request, conversation_id: str):
|
||||
"active_node": active_node,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def _persist_notification_records(result: AgentResult) -> None:
|
||||
payload = result.notification_payload or {}
|
||||
owners = payload.get("owners") or []
|
||||
if not owners:
|
||||
return
|
||||
for owner in owners:
|
||||
create_notification_record(
|
||||
batch_id=payload.get("batch_id", ""),
|
||||
conversation_id=payload.get("conversation_id", ""),
|
||||
product_name=payload.get("product_name", ""),
|
||||
trigger_source="agent_execution",
|
||||
notify_reason=payload.get("notify_reason", "task_completed"),
|
||||
owner_role=owner.get("owner_role", ""),
|
||||
feishu_user_id=owner.get("feishu_user_id", ""),
|
||||
message_status="sent" if result.status == "success" else "failed",
|
||||
web_detail_url="",
|
||||
receipt={"status": result.status},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user