Skip to content

Commit

Permalink
support APPMSGTYPE_URL msg
Browse files Browse the repository at this point in the history
  • Loading branch information
jinqiming committed Mar 31, 2019
1 parent 8cc5737 commit 8c0bc48
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/msghandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,13 @@ async function pickMainInfoFromMsg (msg) {
}
}

if (msg.AppMsgType === AppMsgTypes.APPMSGTYPE_URL) {
return {
'Type': MsgTypeNames.Note,
'Content': decodeURIComponent(msg['EncryFileName'])
}
}

return {
'Type': MsgTypeNames.Note,
'Content': unesacpetext(msg.Content)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chatwe",
"version": "1.0.5",
"version": "1.0.6",
"description": "this is a wechat client sdk. using the protocol of web wechat.",
"main": "index.js",
"scripts": {
Expand Down
13 changes: 13 additions & 0 deletions test/test-pickMainInfoFromMsg.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@ test('wechat pickMainInfoFromMsg MSGTYPE_APP.APPMSGTYPE_REALTIME_SHARE_LOCATION'
t.equal('aaa.xyz', resp.Content)
})

test('wechat pickMainInfoFromMsg MSGTYPE_APP.APPMSGTYPE_URL', async function (t) {
wechat.loginInfo['url'] = Config.BASE_URL
wechat.loginInfo['User'] = {}

let resp = await wechat.pickMainInfoFromMsg({
MsgType: MsgTypes.MSGTYPE_APP,
AppMsgType: AppMsgTypes.APPMSGTYPE_URL,
EncryFileName: 'aaa.xyz'
})
t.equal(resp.Type, 'Note')
t.equal('aaa.xyz', resp.Content)
})

test('wechat pickMainInfoFromMsg MSGTYPE_APP.other', async function (t) {
wechat.loginInfo['url'] = Config.BASE_URL
wechat.loginInfo['User'] = {}
Expand Down

0 comments on commit 8c0bc48

Please sign in to comment.