统一前缀 /api/v1/notification-channels。{platform} 取值:wecom / dingtalk / feishu。
| 方法 | 路径 | 权限 | 说明 |
|---|---|---|---|
| GET | /{platform}/config |
ntc.read | 读取渠道配置;Secret 类字段脱敏返回 |
| PUT | /{platform}/config |
ntc.manage | 保存基础信息与推送场景;保存后自动触发连接验证 |
| POST | /{platform}/verify |
ntc.manage | 手动触发连接验证,返回 token 获取结果与有效期 |
| POST | /{platform}/test-message |
ntc.manage | 向指定手机号/成员发送测试消息 |
配置字段对照:
| 字段 | 企微 | 钉钉 | 飞书 |
|---|---|---|---|
| 企业标识 | corpid | corpid | — |
| 应用凭证 | corpsecret | app_key/app_secret | app_id/app_secret |
| 应用 ID | agentid | agent_id | — |
| 附加 | — | — | 可用范围说明 |
| 方法 | 路径 | 权限 | 说明 |
|---|---|---|---|
| GET | /{platform}/webhooks |
ntc.read | 机器人列表(URL 脱敏) |
| POST | /{platform}/webhooks |
ntc.manage | 新增:群名称、webhook_url、安全方式(sign/keyword/none)、密钥或关键词、推送内容范围 |
| PUT | /{platform}/webhooks/{id} |
ntc.manage | 编辑、启停 |
| DELETE | /{platform}/webhooks/{id} |
ntc.manage | 删除 |
| POST | /{platform}/webhooks/{id}/test |
ntc.manage | 发送群测试消息 |
| 方法 | 路径 | 权限 | 说明 |
|---|---|---|---|
| GET | /{platform}/bindings |
ntc.read | 绑定列表(含未匹配用户) |
| POST | /{platform}/bindings/auto-match |
ntc.manage | 按手机号批量匹配,返回成功/失败明细 |
| PUT | /{platform}/bindings/{user_id} |
ntc.manage | 手工绑定/解绑平台用户 ID |
| 方法 | 路径 | 权限 | 说明 |
|---|---|---|---|
| GET | /{platform}/logs |
ntc.read | 分页 + 按状态/通道类型筛选;保留 90 天 |
| GET | /logs/summary |
ntc.read | 各渠道当日成功/失败计数(总览用) |
| 接口 | 说明 |
|---|---|
scan_pending_notifications(Celery beat,30s/轮) |
轮询 sys_notifications,筛出未投递通知(idempotency_key 判重),逐条调 dispatch |
NotificationDispatchService.dispatch(notification_id) |
按场景路由(key=biz_module.biz_type)分发到通道发送队列;由轮询任务调用,业务模块不调用 |
ChannelAdapter.send(target, payload) |
通道适配器统一接口;各平台实现报文格式化 |