feat: add emit_case_status_webhook helper

This commit is contained in:
2026-05-16 17:06:37 +00:00
parent d5043100a7
commit a0fab1f6de

View File

@@ -19,6 +19,7 @@ from __future__ import annotations
import logging
import os
from datetime import datetime
from typing import Any
import httpx
@@ -81,3 +82,32 @@ async def pc_request(
if raise_on_error:
resp.raise_for_status()
return resp
async def emit_case_status_webhook(
case_number: str,
old_status: str,
new_status: str,
company_id: str | None = None,
run_id: str | None = None,
) -> None:
"""Notify the Paperclip plugin that a case status changed.
Fire-and-forget: logs errors but never raises, so callers aren't blocked.
"""
try:
await pc_request(
"POST",
"/api/plugins/marcusgroup.legal-ai/webhooks/case-status",
json={
"caseNumber": case_number,
"oldStatus": old_status,
"newStatus": new_status,
"companyId": company_id,
"timestamp": datetime.utcnow().isoformat() + "Z",
},
run_id=run_id,
timeout=5.0,
)
except Exception as exc:
logger.warning("emit_case_status_webhook failed: %s", exc)