1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-23 13:42:25 +08:00

feat(miniapp): 小程序订阅消息

1. 用户订阅消息服务端回调处理
2. 用户订阅消息订阅通知事件推送
This commit is contained in:
stuchilde
2021-08-01 19:57:54 +08:00
parent 5d8fd1f5bd
commit c5c764dcc9
6 changed files with 307 additions and 5 deletions

View File

@@ -20,13 +20,29 @@ const (
MsgTypeLink = "link"
//MsgTypeMiniProgramPage 小程序卡片
MsgTypeMiniProgramPage = "miniprogrampage"
//MsgTypeEvent 表示事件推送消息
MsgTypeEvent = "event"
)
const (
//EventSubscribePopup 用户操作订阅通知弹窗事件推送,用户在图文等场景内订阅通知的操作
EventSubscribePopup EventType = "subscribe_msg_popup_event"
//EventSubscribeChange 用户管理订阅通知,用户在服务通知管理页面做通知管理时的操作
EventSubscribeChange = "subscribe_msg_change_event"
//EventSubscribeSent 发送订阅通知,调用 bizsend 接口发送通知
EventSubscribeSent = "subscribe_msg_sent_event"
)
const (
InfoTypeAcceptSubscribeMessage InfoType = "accept"
InfoTypeRejectSubscribeMessage = "reject"
)
// CommonToken 消息中通用的结构
type CommonToken struct {
XMLName xml.Name `xml:"xml"`
ToUserName string `xml:"ToUserName"`
FromUserName string `xml:"FromUserName"`
ToUserName CDATA `xml:"ToUserName"`
FromUserName CDATA `xml:"FromUserName"`
CreateTime int64 `xml:"CreateTime"`
MsgType MsgType `xml:"MsgType"`
}
@@ -54,4 +70,35 @@ type MiniProgramMixMessage struct {
// 进入会话事件
Event string `xml:"Event"`
SessionFrom string `xml:"SessionFrom"`
// 用户操作订阅通知弹窗消息回调
SubscribeMsgPopupEvent struct {
List []SubscribeMessageList `xml:"List"`
} `xml:"SubscribeMsgPopupEvent"`
// 用户管理订阅通知回调
SubscribeMsgChangeEvent struct {
List []SubscribeMessageList `xml:"List"`
} `xml:"SubscribeMsgChangeEvent"`
// 用户发送订阅通知回调
SubscribeMsgSentEvent struct {
List []SubscribeMessageList `xml:"List"`
} `xml:"SubscribeMsgSentEvent"`
}
type SubscribeMessageList struct {
TemplateId string `xml:"TemplateId"`
SubscribeStatusString string `xml:"SubscribeStatusString"`
PopupScene string `xml:"PopupScene"`
}
// EncryptedXMLMsg 安全模式下的消息体
type EncryptedXMLMsg struct {
XMLName struct{} `xml:"xml" json:"-"`
ToUserName string `xml:"ToUserName" json:"toUserName"`
EncryptedMsg string `xml:"Encrypt" json:"Encrypt"`
}
// CDATA 使用这种类型,在序列化 xml 时文本会被解析器忽略
type CDATA string