wechat 0.13.3 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +9 -4
- data/README-CN.md +13 -1
- data/README.md +13 -1
- data/bin/wechat +0 -2
- data/lib/wechat/api_loader.rb +1 -1
- data/lib/wechat/concern/qcloud.rb +1 -1
- data/lib/wechat/controller_api.rb +5 -5
- data/lib/wechat/corp_api.rb +16 -0
- data/lib/wechat/qcloud/token.rb +1 -1
- data/lib/wechat/responder.rb +16 -0
- data/lib/wechat/ticket/jsapi_base.rb +1 -1
- data/lib/wechat/token/access_token_base.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +26 -26
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 90aad3955d68b49a3eaf8774fdc247a6f0f8c5e7887b3abde7249fd4f4d6c64b
|
|
4
|
+
data.tar.gz: 7c6ca0a6bd601a5527c8e99db9ddc687a4a057131dd3d6e1556ae0677781ddcd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8e83f65806db0a976da02ed4aa1bb74554af42ee0e1e9c5c9c484ec23f46a34d268dbe1396fcd2e0d6b25e70f0d99731a206ce6468a6889bc3ae523997947564
|
|
7
|
+
data.tar.gz: a04c6ee54cf2280e2a45bc0eea3ba2d6a1d8e45e5d02e443e2c36b524da09ec96a5b4645b7e3ecfa3c9e1754ca31a40a8683c780d4e9fcd93f417be6da70e247
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/CHANGELOG.md
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## v0.
|
|
3
|
+
## v0.14.0 (released at 2021-09-15)
|
|
4
|
+
|
|
5
|
+
* Add beta support for Conversation archive in WeCom, discuss at #303
|
|
6
|
+
* Avoid using 1.hour in early loading to improve Rails 6+ compatibility.
|
|
7
|
+
|
|
8
|
+
## v0.13.3 (released at 2021-06-18)
|
|
4
9
|
|
|
5
10
|
* material add video description by @zlei1 #301
|
|
6
11
|
* Allow using http v5
|
|
7
12
|
|
|
8
|
-
## v0.13.2 (released at
|
|
13
|
+
## v0.13.2 (released at 2021-04-21)
|
|
9
14
|
|
|
10
15
|
* New material_add_news API, by @zlei1 #300
|
|
11
16
|
* Support open_tag, by @xiajian2019 #299
|
|
12
17
|
|
|
13
|
-
## v0.13.1 (released at
|
|
18
|
+
## v0.13.1 (released at 2021-03-15)
|
|
14
19
|
|
|
15
20
|
* Fix MpApi initialize bug, by @hardywu #296
|
|
16
21
|
|
|
17
|
-
## v0.13.0 (released at
|
|
22
|
+
## v0.13.0 (released at 2021-03-03)
|
|
18
23
|
|
|
19
24
|
* Support zeitwerk only and Rails 6+ only.
|
|
20
25
|
* Support Ruby 2.6+ only.
|
data/README-CN.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
WeChat [](https://rubygems.org/gems/wechat) [](https://travis-ci.com/github/Eric-Guo/wechat) [](https://codeclimate.com/github/Eric-Guo/wechat/maintainability) [](https://codeclimate.com/github/Eric-Guo/wechat/test_coverage)
|
|
1
|
+
WeChat [](https://rubygems.org/gems/wechat) [](https://travis-ci.com/github/Eric-Guo/wechat) [](https://codeclimate.com/github/Eric-Guo/wechat/maintainability) [](https://codeclimate.com/github/Eric-Guo/wechat/test_coverage)
|
|
2
2
|
======
|
|
3
3
|
|
|
4
4
|
[](https://gitter.im/Eric-Guo/wechat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
@@ -794,6 +794,18 @@ class WechatsController < ActionController::Base
|
|
|
794
794
|
request.reply.success # request is XML result hash.
|
|
795
795
|
end
|
|
796
796
|
|
|
797
|
+
# 客户同意进行聊天内容存档事件回调
|
|
798
|
+
on :change_external_contact do |request|
|
|
799
|
+
# https://open.work.weixin.qq.com/api/doc/90000/90135/92005
|
|
800
|
+
request.reply.success # request is XML result hash.
|
|
801
|
+
end
|
|
802
|
+
|
|
803
|
+
# 会话事件回调
|
|
804
|
+
on :msgaudit_notify do |request|
|
|
805
|
+
# https://open.work.weixin.qq.com/api/doc/90000/90135/95039
|
|
806
|
+
request.reply.success # request is XML result hash.
|
|
807
|
+
end
|
|
808
|
+
|
|
797
809
|
# 当无任何 responder 处理用户信息时,使用这个 responder 处理
|
|
798
810
|
on :fallback, respond: 'fallback message'
|
|
799
811
|
end
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
WeChat [](https://rubygems.org/gems/wechat) [](https://travis-ci.com/github/Eric-Guo/wechat) [](https://codeclimate.com/github/Eric-Guo/wechat/maintainability) [](https://codeclimate.com/github/Eric-Guo/wechat/test_coverage)
|
|
1
|
+
WeChat [](https://rubygems.org/gems/wechat) [](https://travis-ci.com/github/Eric-Guo/wechat) [](https://codeclimate.com/github/Eric-Guo/wechat/maintainability) [](https://codeclimate.com/github/Eric-Guo/wechat/test_coverage)
|
|
2
2
|
======
|
|
3
3
|
|
|
4
4
|
[](https://gitter.im/Eric-Guo/wechat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
@@ -828,6 +828,18 @@ class WechatsController < ActionController::Base
|
|
|
828
828
|
request.reply.success # request is XML result hash.
|
|
829
829
|
end
|
|
830
830
|
|
|
831
|
+
# The customer agrees to call back the chat content archive event
|
|
832
|
+
on :change_external_contact do |request|
|
|
833
|
+
# https://open.work.weixin.qq.com/api/doc/90000/90135/92005
|
|
834
|
+
request.reply.success # request is XML result hash.
|
|
835
|
+
end
|
|
836
|
+
|
|
837
|
+
# Session event callback
|
|
838
|
+
on :msgaudit_notify do |request|
|
|
839
|
+
# https://open.work.weixin.qq.com/api/doc/90000/90135/95039
|
|
840
|
+
request.reply.success # request is XML result hash.
|
|
841
|
+
end
|
|
842
|
+
|
|
831
843
|
# If no match above will fallback to below
|
|
832
844
|
on :fallback, respond: 'fallback message'
|
|
833
845
|
end
|
data/bin/wechat
CHANGED
data/lib/wechat/api_loader.rb
CHANGED
|
@@ -61,7 +61,7 @@ module Wechat
|
|
|
61
61
|
cfg[:timeout] ||= 20
|
|
62
62
|
cfg[:qcloud_token_lifespan] ||= 7200
|
|
63
63
|
cfg[:have_session_class] = class_exists?('WechatSession')
|
|
64
|
-
cfg[:oauth2_cookie_duration] ||= 1
|
|
64
|
+
cfg[:oauth2_cookie_duration] ||= 3600 # 1 hour
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
# create config object using raw config data
|
|
@@ -99,7 +99,7 @@ module Wechat
|
|
|
99
99
|
form_file = file.is_a?(HTTP::FormData::File) ? file : HTTP::FormData::File.new(file)
|
|
100
100
|
form_data = HTTP::FormData.create({ key: q_path,
|
|
101
101
|
Signature: signature,
|
|
102
|
-
|
|
102
|
+
'x-cos-security-token': x_cos_security_token,
|
|
103
103
|
'x-cos-meta-fileid': x_cos_meta_fileid,
|
|
104
104
|
file: form_file })
|
|
105
105
|
client.httprb.post(upload_url, form: form_data, ssl_context: client.ssl_context)
|
|
@@ -53,9 +53,9 @@ module Wechat
|
|
|
53
53
|
yield openid, { 'openid' => openid, 'unionid' => unionid, 'access_token' => we_token }
|
|
54
54
|
elsif params[:code].present? && params[:state] == oauth2_params[:state]
|
|
55
55
|
access_info = wechat(account).web_access_token(params[:code])
|
|
56
|
-
cookies.signed_or_encrypted[:we_openid] = { value: access_info['openid'], expires: self.class.oauth2_cookie_duration
|
|
57
|
-
cookies.signed_or_encrypted[:we_unionid] = { value: access_info['unionid'], expires: self.class.oauth2_cookie_duration
|
|
58
|
-
cookies.signed_or_encrypted[:we_access_token] = { value: access_info['access_token'], expires: self.class.oauth2_cookie_duration
|
|
56
|
+
cookies.signed_or_encrypted[:we_openid] = { value: access_info['openid'], expires: (Time.now + self.class.oauth2_cookie_duration) }
|
|
57
|
+
cookies.signed_or_encrypted[:we_unionid] = { value: access_info['unionid'], expires: (Time.now + self.class.oauth2_cookie_duration) }
|
|
58
|
+
cookies.signed_or_encrypted[:we_access_token] = { value: access_info['access_token'], expires: (Time.now + self.class.oauth2_cookie_duration) }
|
|
59
59
|
yield access_info['openid'], access_info
|
|
60
60
|
else
|
|
61
61
|
redirect_to generate_oauth2_url(oauth2_params), allow_other_host: true
|
|
@@ -69,8 +69,8 @@ module Wechat
|
|
|
69
69
|
yield userid, { 'UserId' => userid, 'DeviceId' => deviceid }
|
|
70
70
|
elsif params[:code].present? && params[:state] == oauth2_params[:state]
|
|
71
71
|
userinfo = wechat(account).getuserinfo(params[:code])
|
|
72
|
-
cookies.signed_or_encrypted[:we_userid] = { value: userinfo['UserId'], expires: self.class.oauth2_cookie_duration
|
|
73
|
-
cookies.signed_or_encrypted[:we_deviceid] = { value: userinfo['DeviceId'], expires: self.class.oauth2_cookie_duration
|
|
72
|
+
cookies.signed_or_encrypted[:we_userid] = { value: userinfo['UserId'], expires: (Time.now + self.class.oauth2_cookie_duration) }
|
|
73
|
+
cookies.signed_or_encrypted[:we_deviceid] = { value: userinfo['DeviceId'], expires: (Time.now + self.class.oauth2_cookie_duration) }
|
|
74
74
|
yield userinfo['UserId'], userinfo
|
|
75
75
|
else
|
|
76
76
|
redirect_to generate_oauth2_url(oauth2_params), allow_other_host: true
|
data/lib/wechat/corp_api.rb
CHANGED
|
@@ -188,5 +188,21 @@ module Wechat
|
|
|
188
188
|
def custom_message_send(message)
|
|
189
189
|
post 'message/send', message.is_a?(Wechat::Message) ? message.agent_id(agentid).to_json : JSON.generate(message.merge(agent_id: agentid)), content_type: :json
|
|
190
190
|
end
|
|
191
|
+
|
|
192
|
+
def msgaudit_get_permit_user_list(type = nil)
|
|
193
|
+
post 'msgaudit/get_permit_user_list', JSON.generate(type: type)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def msgaudit_check_single_agree(info)
|
|
197
|
+
post 'msgaudit/get_permit_user_list', JSON.generate(info: info)
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def msgaudit_check_room_agree(roomid)
|
|
201
|
+
post 'msgaudit/check_room_agree', JSON.generate(roomid: roomid)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def msgaudit_groupchat(roomid)
|
|
205
|
+
post 'msgaudit/groupchat/get', JSON.generate(roomid: roomid)
|
|
206
|
+
end
|
|
191
207
|
end
|
|
192
208
|
end
|
data/lib/wechat/qcloud/token.rb
CHANGED
|
@@ -22,7 +22,7 @@ module Wechat
|
|
|
22
22
|
def token(tries = 2)
|
|
23
23
|
# Possible two worker running, one worker refresh ticket, other unaware, so must read every time
|
|
24
24
|
read_qcloud_token_from_store
|
|
25
|
-
refresh if remain_life_seconds < @random_generator.rand(30..3 * 60)
|
|
25
|
+
refresh if remain_life_seconds < @random_generator.rand(30..(3 * 60))
|
|
26
26
|
qcloud_token
|
|
27
27
|
rescue AccessTokenExpiredError
|
|
28
28
|
access_token.refresh
|
data/lib/wechat/responder.rb
CHANGED
|
@@ -50,6 +50,10 @@ module Wechat
|
|
|
50
50
|
user_defined_location_responders << config
|
|
51
51
|
when :label_location
|
|
52
52
|
user_defined_label_location_responders << config
|
|
53
|
+
when :change_external_contact
|
|
54
|
+
user_defined_change_external_contact_responders << config
|
|
55
|
+
when :msgaudit_notify
|
|
56
|
+
user_defined_msgaudit_notify_responders << config
|
|
53
57
|
else
|
|
54
58
|
user_defined_responders(message_type) << config
|
|
55
59
|
end
|
|
@@ -84,6 +88,14 @@ module Wechat
|
|
|
84
88
|
@user_defined_label_location_responders ||= []
|
|
85
89
|
end
|
|
86
90
|
|
|
91
|
+
def user_defined_change_external_contact_responders
|
|
92
|
+
@user_defined_change_external_contact_responders ||= []
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def user_defined_msgaudit_notify_responders
|
|
96
|
+
@user_defined_msgaudit_notify_responders ||= []
|
|
97
|
+
end
|
|
98
|
+
|
|
87
99
|
def user_defined_responders(type)
|
|
88
100
|
@responders ||= {}
|
|
89
101
|
@responders[type] ||= []
|
|
@@ -109,6 +121,10 @@ module Wechat
|
|
|
109
121
|
yield(* user_defined_batch_job_responders(message[:BatchJob][:JobType]), message[:BatchJob])
|
|
110
122
|
elsif message[:Event] == 'location'
|
|
111
123
|
yield(* user_defined_location_responders, message)
|
|
124
|
+
elsif message[:Event] == 'change_external_contact'
|
|
125
|
+
yield(* user_defined_change_external_contact_responders, message)
|
|
126
|
+
elsif message[:Event] == 'msgaudit_notify'
|
|
127
|
+
yield(* user_defined_msgaudit_notify_responders, message)
|
|
112
128
|
else
|
|
113
129
|
yield(* match_responders(responders, message[:Event]))
|
|
114
130
|
end
|
|
@@ -18,7 +18,7 @@ module Wechat
|
|
|
18
18
|
def ticket(tries = 2)
|
|
19
19
|
# Possible two worker running, one worker refresh ticket, other unaware, so must read every time
|
|
20
20
|
read_ticket_from_store
|
|
21
|
-
refresh if remain_life_seconds < @random_generator.rand(30..3 * 60)
|
|
21
|
+
refresh if remain_life_seconds < @random_generator.rand(30..(3 * 60))
|
|
22
22
|
access_ticket
|
|
23
23
|
rescue AccessTokenExpiredError
|
|
24
24
|
access_token.refresh
|
|
@@ -16,7 +16,7 @@ module Wechat
|
|
|
16
16
|
def token
|
|
17
17
|
# Possible two worker running, one worker refresh token, other unaware, so must read every time
|
|
18
18
|
read_token_from_store
|
|
19
|
-
refresh if remain_life_seconds < @random_generator.rand(30..3 * 60)
|
|
19
|
+
refresh if remain_life_seconds < @random_generator.rand(30..(3 * 60))
|
|
20
20
|
access_token
|
|
21
21
|
end
|
|
22
22
|
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wechat
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Skinnyworm
|
|
@@ -11,31 +11,31 @@ bindir: bin
|
|
|
11
11
|
cert_chain:
|
|
12
12
|
- |
|
|
13
13
|
-----BEGIN CERTIFICATE-----
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
14
|
+
MIIEODCCAqCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBhlcmlj
|
|
15
|
+
L0RDPWNsb3VkLW1lcy9EQz1jb20wHhcNMjEwOTE1MDIxMDMzWhcNMjIwOTE1MDIx
|
|
16
|
+
MDMzWjAjMSEwHwYDVQQDDBhlcmljL0RDPWNsb3VkLW1lcy9EQz1jb20wggGiMA0G
|
|
17
|
+
CSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDfweHJdAqu5+BQ6t+F923czZvUynqe
|
|
18
|
+
DyacqWVUbDg53oVwYxldDNqUea5hMlSs1UWj2sJ5ZHiU02ly0QVyDCw/5pFP2CKJ
|
|
19
|
+
ukQbw35ZoCF0t2i0/GPYAtBMxb1qUynkxDAtCefQG33lBt2u9scgE9xOIiPrxtJg
|
|
20
|
+
shl3XFYmOx1ol66JR540l7NBS1OHR7UV6WiJrRW1cZTcR+py7jIbo6ud/rhZVHCO
|
|
21
|
+
B2RTZtpH1I7ilknT1/NXMX6aw+XoNda4w+4lsrHfqKssfwJcsGMq1IbbG8illxRT
|
|
22
|
+
wsYLiUXNJaAacT9HVO4B0jIFPP5Me7FIkiqZZKr7uyHNQE0S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----END CERTIFICATE-----
|
|
38
|
-
date: 2021-
|
|
38
|
+
date: 2021-09-15 00:00:00.000000000 Z
|
|
39
39
|
dependencies:
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: activesupport
|
|
@@ -258,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
258
258
|
- !ruby/object:Gem::Version
|
|
259
259
|
version: '0'
|
|
260
260
|
requirements: []
|
|
261
|
-
rubygems_version: 3.2.
|
|
261
|
+
rubygems_version: 3.2.27
|
|
262
262
|
signing_key:
|
|
263
263
|
specification_version: 4
|
|
264
264
|
summary: DSL for wechat message handling and API
|
metadata.gz.sig
CHANGED
|
Binary file
|