Implement webhook

This commit is contained in:
Xin Wang
2026-08-07 14:08:49 +08:00
parent 39ee5ef96e
commit b2e99baa19
14 changed files with 886 additions and 34 deletions
+35
View File
@@ -566,3 +566,38 @@ class ConversationListOut(CamelModel):
total: int
page: int
page_size: int
# ---------- 站点级 Webhook ----------
class AnalysisWebhookSettingOut(CamelModel):
enabled: bool = False
url: str = ""
secret_configured: bool = False
updated_at: datetime | None = None
class AnalysisWebhookSettingUpdate(CamelModel):
enabled: bool = False
url: str = Field(default="", max_length=2048)
secret: str | None = Field(default=None, max_length=512)
clear_secret: bool = False
@model_validator(mode="after")
def validate_enabled_url(self):
self.url = self.url.strip()
if self.enabled and not self.url:
raise ValueError("启用 Webhook 时必须填写 URL")
return self
class AnalysisWebhookTestIn(CamelModel):
url: str = Field(min_length=1, max_length=2048)
secret: str | None = Field(default=None, max_length=512)
class AnalysisWebhookTestOut(CamelModel):
ok: bool
status_code: int | None = None
latency_ms: int | None = None
message: str
payload: dict[str, Any]