Skip to content

Commit

Permalink
Feature: improve code message subscribe (#739)
Browse files Browse the repository at this point in the history
* fix

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

1. 用户订阅消息服务端回调处理
2. 用户订阅消息订阅通知事件推送

Co-authored-by: houseme <qzg40737@163.com>

* feat: improve subscribe msg

* feat: add v1.21 and feature branch

* feat: improve code for subscribe

* test

* test

* fix

* fix

* improve comment

* improve code for message

* improve code for unmarshal message

* improve code for message

---------

Co-authored-by: Ralph Maas <stuchilde@outlook.com>
  • Loading branch information
houseme and Ralph Maas authored Nov 2, 2023
1 parent d4fd145 commit 56a3734
Show file tree
Hide file tree
Showing 8 changed files with 292 additions and 73 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: Go

on:
push:
branches: [ master,release-*,v2 ]
branches: [ master,release-*,v2,feature/** ]
pull_request:
branches: [ master,release-*,v2 ]
branches: [ master,release-*,v2,feature/** ]

jobs:
golangci:
strategy:
matrix:
go-version: [ '1.16','1.17','1.18','1.19','1.20' ]
go-version: [ '1.16','1.17','1.18','1.19','1.20','1.21' ]
name: golangci-lint
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
# strategy set
strategy:
matrix:
go: [ '1.16','1.17','1.18','1.19','1.20' ]
go: [ '1.16','1.17','1.18','1.19','1.20','1.21' ]

steps:
- uses: actions/checkout@v3
Expand Down
20 changes: 10 additions & 10 deletions domain/openapi/mgnt.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package openapi

import "github.com/silenceper/wechat/v2/util"

// GetAPIQuotaParams 查询API调用额度参数
// GetAPIQuotaParams 查询 API 调用额度参数
type GetAPIQuotaParams struct {
CgiPath string `json:"cgi_path"` // api的请求地址,例如"/cgi-bin/message/custom/send";不要前缀“https://api.weixin.qq.com” ,也不要漏了"/",否则都会76003的报错
CgiPath string `json:"cgi_path"` // api 的请求地址,例如"/cgi-bin/message/custom/send";不要前缀“https://api.weixin.qq.com” ,也不要漏了"/",否则都会 76003 的报错
}

// APIQuota API调用额度
// APIQuota API 调用额度
type APIQuota struct {
util.CommonError
Quota struct {
Expand All @@ -17,20 +17,20 @@ type APIQuota struct {
} `json:"quota"` // 详情
}

// GetRidInfoParams 查询rid信息参数
// GetRidInfoParams 查询 rid 信息参数
type GetRidInfoParams struct {
Rid string `json:"rid"` // 调用接口报错返回的rid
Rid string `json:"rid"` // 调用接口报错返回的 rid
}

// RidInfo rid信息
// RidInfo rid 信息
type RidInfo struct {
util.CommonError
Request struct {
InvokeTime int64 `json:"invoke_time"` // 发起请求的时间戳
CostInMs int64 `json:"cost_in_ms"` // 请求毫秒级耗时
RequestURL string `json:"request_url"` // 请求的URL参数
RequestBody string `json:"request_body"` // post请求的请求参数
RequestURL string `json:"request_url"` // 请求的 URL 参数
RequestBody string `json:"request_body"` // post 请求的请求参数
ResponseBody string `json:"response_body"` // 接口请求返回参数
ClientIP string `json:"client_ip"` // 接口请求的客户端ip
} `json:"request"` // 该rid对应的请求详情
ClientIP string `json:"client_ip"` // 接口请求的客户端 ip
} `json:"request"` // 该 rid 对应的请求详情
}
4 changes: 2 additions & 2 deletions miniprogram/message/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const (
MsgTypeMiniProgramPage = "miniprogrampage"
// MsgTypeEvent 事件
MsgTypeEvent MsgType = "event"
// DataTypeXML XML格式数据
// DataTypeXML XML 格式数据
DataTypeXML = "xml"
// DataTypeJSON JSON格式数据
// DataTypeJSON JSON 格式数据
DataTypeJSON = "json"
)

Expand Down
4 changes: 2 additions & 2 deletions miniprogram/message/customer_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type MediaText struct {
Content string `json:"content"`
}

// MediaResource 消息使用的临时素材id
// MediaResource 消息使用的临时素材 id
type MediaResource struct {
MediaID string `json:"media_id"`
}
Expand All @@ -51,7 +51,7 @@ type MediaLink struct {

// CustomerMessage 客服消息
type CustomerMessage struct {
ToUser string `json:"touser"` // 接受者OpenID
ToUser string `json:"touser"` // 接受者 OpenID
Msgtype MsgType `json:"msgtype"` // 客服消息类型
Text *MediaText `json:"text,omitempty"` // 可选
Image *MediaResource `json:"image,omitempty"` // 可选
Expand Down
Loading

0 comments on commit 56a3734

Please sign in to comment.