Skip to content

Commit 2a9b78b

Browse files
authored
Merge pull request #543 from ArtisanCloud/develop
Develop
2 parents eea7d1c + 4ce7c8d commit 2a9b78b

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/kernel/Encryptor.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"encoding/base64"
1010
"encoding/binary"
1111
"encoding/hex"
12+
"encoding/json"
1213
"encoding/xml"
1314
"fmt"
1415
"github.com/ArtisanCloud/PowerLibs/v3/object"
@@ -41,17 +42,17 @@ type CDATA struct {
4142
}
4243

4344
type WeComReplyMsg struct {
44-
XMLName xml.Name `xml:"xml"`
45-
Encrypt CDATA `xml:"Encrypt"`
46-
Signature CDATA `xml:"MsgSignature"`
47-
Timestamp string `xml:"TimeStamp"`
48-
Nonce CDATA `xml:"Nonce"`
45+
XMLName xml.Name `xml:"xml" json:"-"`
46+
Encrypt CDATA `xml:"Encrypt" json:"Encrypt"`
47+
Signature CDATA `xml:"MsgSignature" json:"Signature"`
48+
Timestamp string `xml:"TimeStamp" json:"Timestamp"`
49+
Nonce CDATA `xml:"Nonce" json:"Nonce"`
4950
}
5051

5152
type WeComRecvMsg struct {
52-
ToUserName string `xml:"ToUserName"`
53-
Encrypt string `xml:"Encrypt"`
54-
AgentID string `xml:"AgentID"`
53+
ToUserName string `xml:"ToUserName" json:"ToUserName"`
54+
Encrypt string `xml:"Encrypt" json:"Encrypt"`
55+
AgentID string `xml:"AgentID" json:"AgentID"`
5556
}
5657

5758
type Encryptor struct {
@@ -147,7 +148,13 @@ func (encryptor *Encryptor) Encrypt(msg, nonce, timestamp string) ([]byte, *supp
147148
// Decrypt decrypt xml msg and return xml
148149
func (encryptor *Encryptor) Decrypt(content []byte, msgSignature, nonce, timestamp string) ([]byte, *support.CryptError) {
149150
var msg4Recv WeComRecvMsg
150-
err := xml.Unmarshal(content, &msg4Recv)
151+
var err error
152+
// 根据第一个字符判断是json还是xml
153+
if content[0] == '<' {
154+
err = xml.Unmarshal(content, &msg4Recv)
155+
} else if content[0] == '{' {
156+
err = json.Unmarshal(content, &msg4Recv)
157+
}
151158

152159
if err != nil {
153160
return nil, support.NewCryptError(ErrorDecryptAes, err.Error())

src/officialAccount/menu/response/responseMenuCurrentSelf.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type SelfButton struct {
3232
Name string `json:"name"`
3333
Key string `json:"key"`
3434
Value string `json:"value,omitempty"`
35+
URL string `json:"url,omitempty"`
3536
SubButtons *SubButton `json:"sub_button"`
3637
}
3738

0 commit comments

Comments
 (0)