NotificationAPI - infoplus/docs GitHub Wiki
通知api支持外部推送接口,该http接口需要满足以下规范
# API-1: 发送通知
[PUT|POST] /notification @return Response<>
# API-2: 查询支持的通知渠道列表
GET /channels @return Response<Channel>
# API-3: 查询通知发送状态
GET /notification/{ids} @return Response<Notification>
# API-4: 查询用户通知列表
GET /me/notifications @return Response<Notification>
GET /user/{id}/notifications @return Response<Notification>
# API-5: 标记为已读,仅支持Web渠道
POST /me/notification/{ids}?action=read @return Response<Notification>
POST /user/{id}/notification/{ids}?action=read @return Response<Notification>
- 发送接口为了避免部分防火墙限制,put和post都支持
- 返回值是Response数据类型(见下方定义)json格式
参数在body里,是以下格式的json字串,从body里取出后需要解析一下使用
// TYPE:Notification
{
"id":{guid}, // 通知的guid,可以忽略
"name":{string}, // 标题
"content":{string}, // 正文,纯文本格式
"body":{string}, // 正文,富文本格式
"html":{string}, // 正文,html格式
"contentAbstract": {string}, // 正文摘要。可选,如给出,优先应用于sms渠道(小于2048个字符)。
"tags": {string}, // 标签,可选,用于Web展示时的分类
"channels":[{string}], // 通知推送渠道数组,内置渠道为email和sms,其他渠道需通过ChannelAPI定制
"emails":[{string}], // 收信人邮件列表,对应于email渠道
"phones":[{string}], // 收信人手机列表,对应于sms渠道
"bizId":{string}, // 用于关联发送方具体业务的UUID。发送方提供,2023/09新增
"bizInfo":[{ // 用于关联发送方具体业务的更复杂的结构。发送方提供,2025/05新增
"bizType": {string}, // 业务实体类型,参考`业务类型枚举`[7]
"bizIds": [{string}], // 关联业务标识,内容为对应`bizType`的业务实体标识
}],
"users":[{ // 收信人列表,对应于其他渠道,比如外部ChannelAPI
"id":{guid}, // 无意义的唯一id
"name":{string}, // 实名
"account":{string}, // 账号,根据调用者token.principal确定账号主体[5]
"openid":{string}, // 可选,指定使用`OPENID`的账号主体[5],2022/06/14新增
"userName":{string}, // 可选,指定使用`USER_NAME`的账号主体[5],2022/06/14新增
"userCode":{string}, // 可选,指定使用`USER_CODE`的账号主体[5],2022/06/14新增
"email":{string}, // 邮箱
"phone":{string}, // 手机号
"enterprise": {enterprise} // 用户所属租户信息
}],
"userFilters":[{string}], // 收信人UserFilter[6]列表
}
说明
- 目前通知的内容仅存在于content字段,其余几个字段body,html,abstract预留备用。
- users是用户账号数组,可以用于一条消息发送给多个用户,目前基本是一个消息发送给一个用户,但不排除将来扩展。
- user的数据格式,和InfoPlusAPI的Profile结构兼容
- channels是推送方式数组,例如“channels”:["weixin","weibo","qq"] 。
- 账号主体参考文档:Principal
- UserFilter格式参考:UserFilter.
- 业务类型枚举:
WORKFLOW
(流程编码)、WORKFLOW_ENTRY
(流程流水号)、WORKFLOW_TASK
(流程流水任务号)
Response<T>
// TYPE:Response,返回值wrapper
{
"errno": {int}, // 成功返回0,失败返回错误号
"error": {string}, // 如果有错,返回错误信息,如果成功返回空字符串
"entities": [{T}], // 总是空数组
"total": {int} // entities总数量,总是0
}
// TYPE: Channel
{
"name": {string} // 渠道编码
"text": {string} // 渠道显示名
"recipientTypes": [{string}] // 支持通知接收者的类型,枚举:[email|phone|user]
}
一个典型的成功返回的信息为{ “errno”:0, “error”:””, “total”:0, “entities”:[]} json序列化后的字串