feat: add crm dead-letter operations and benchmark summary

This commit is contained in:
Codex
2026-06-30 23:07:43 +08:00
parent 90ad9e90a3
commit 9891fe9ef3
22 changed files with 1284 additions and 110 deletions
+32 -1
View File
@@ -45,6 +45,9 @@ WORKER_CRM_ALLOW_INSECURE_LOCALHOST=false
PUT /api/crm/config
GET /api/crm/config
GET /api/crm/queue
GET /api/crm/dead-letters
GET /api/crm/queue/logs
POST /api/crm/queue/action
POST /api/tenant-admin/students/crm-push
```
@@ -92,6 +95,34 @@ pending -> discarded
每次尝试都会写入 `crm_webhook_log`,日志只记录 provider、目标 host、请求体和响应摘要,不写入 webhook secret。
## 死信运营
CRM 失败运营入口已经落地,租户后台只通过后端 API 处理失败任务:
```text
GET /api/crm/dead-letters?status=failed&limit=20
GET /api/crm/queue/logs?queueId=<crmQueueId>
POST /api/crm/queue/action
```
`POST /api/crm/queue/action` 当前支持:
```json
{ "queueId": "<crmQueueId>", "action": "retry", "reason": "确认 webhook 已恢复" }
```
```json
{ "queueId": "<crmQueueId>", "action": "ignore", "reason": "租户确认不再推送" }
```
安全边界:
- 读取失败池、查看日志和重试/忽略都要求租户内 `crm:write` 权限。
- `retry` 会把 `failed/discarded/retrying/pending` 任务重置为 `pending`,清空错误并记录操作者。
- `ignore` 只允许处理 `failed/discarded` 任务,会标记为 `discarded` 并记录原因。
- API 会递归脱敏 payload、日志和审计响应中的 secret、token、authorization、password 等敏感字段。
- 所有动作都会写入 `crm_webhook_log` 和租户审计日志,前端不能直接改 `crm_webhook_queue`
## 安全边界
- 前端不能直接写 `crm_webhook_queue`
@@ -105,5 +136,5 @@ pending -> discarded
## 后续增强
- 钉钉/飞书/企微富卡片模板。
- 失败告警和死信运营后台
- 外部失败告警升级
- 更细销售转化看板。