wechat 0.13.3 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c780f63273dd1e380af79ce5feb14fc9787f0abd47ebc797ae6528b706533e6b
4
- data.tar.gz: f711e6f2f766db3424f827b0806ea3275fbbaacd33ab777e330eb0e73d2e1161
3
+ metadata.gz: 90aad3955d68b49a3eaf8774fdc247a6f0f8c5e7887b3abde7249fd4f4d6c64b
4
+ data.tar.gz: 7c6ca0a6bd601a5527c8e99db9ddc687a4a057131dd3d6e1556ae0677781ddcd
5
5
  SHA512:
6
- metadata.gz: 83ace7fd48928bd1fb75845294ceef130ad39359b281e903ea7c87cb3e42d7a4e677677df4dfa2ae19ee7561524c6f9ec8e9ae6df13677ecbc828fb4a6b7a93c
7
- data.tar.gz: 061b40b05dd8f4114f582cf05f2fa18da8f8616671dada4c475d5a80838d985c65ab996843745cb7f15d0fd8c8632018cd285d49653eb0b4b443f19500919880
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.13.3 (released at 6/18/2021)
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 4/21/2021)
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 3/15/2021)
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 3/3/2021)
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 [![Gem Version](https://badge.fury.io/rb/wechat.svg)](https://rubygems.org/gems/wechat) [![Build Status](https://travis-ci.com/Eric-Guo/wechat.svg)](https://travis-ci.com/github/Eric-Guo/wechat) [![Maintainability](https://api.codeclimate.com/v1/badges/12885358487c13e91e00/maintainability)](https://codeclimate.com/github/Eric-Guo/wechat/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/12885358487c13e91e00/test_coverage)](https://codeclimate.com/github/Eric-Guo/wechat/test_coverage)
1
+ WeChat [![Gem Version](https://badge.fury.io/rb/wechat.svg)](https://rubygems.org/gems/wechat) [![Build Status](https://app.travis-ci.com/Eric-Guo/wechat.svg?branch=main)](https://travis-ci.com/github/Eric-Guo/wechat) [![Maintainability](https://api.codeclimate.com/v1/badges/12885358487c13e91e00/maintainability)](https://codeclimate.com/github/Eric-Guo/wechat/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/12885358487c13e91e00/test_coverage)](https://codeclimate.com/github/Eric-Guo/wechat/test_coverage)
2
2
  ======
3
3
 
4
4
  [![Join the chat](https://badges.gitter.im/Join%20Chat.svg)](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 [![Gem Version](https://badge.fury.io/rb/wechat.svg)](https://rubygems.org/gems/wechat) [![Build Status](https://travis-ci.com/Eric-Guo/wechat.svg)](https://travis-ci.com/github/Eric-Guo/wechat) [![Maintainability](https://api.codeclimate.com/v1/badges/12885358487c13e91e00/maintainability)](https://codeclimate.com/github/Eric-Guo/wechat/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/12885358487c13e91e00/test_coverage)](https://codeclimate.com/github/Eric-Guo/wechat/test_coverage)
1
+ WeChat [![Gem Version](https://badge.fury.io/rb/wechat.svg)](https://rubygems.org/gems/wechat) [![Build Status](https://app.travis-ci.com/Eric-Guo/wechat.svg?branch=main)](https://travis-ci.com/github/Eric-Guo/wechat) [![Maintainability](https://api.codeclimate.com/v1/badges/12885358487c13e91e00/maintainability)](https://codeclimate.com/github/Eric-Guo/wechat/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/12885358487c13e91e00/test_coverage)](https://codeclimate.com/github/Eric-Guo/wechat/test_coverage)
2
2
  ======
3
3
 
4
4
  [![Join the chat](https://badges.gitter.im/Join%20Chat.svg)](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
@@ -6,8 +6,6 @@ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
6
6
  require 'thor'
7
7
  require 'wechat'
8
8
  require 'json'
9
- require 'active_support/core_ext'
10
- require 'active_support/json'
11
9
  require 'fileutils'
12
10
  require 'yaml'
13
11
  require 'cgi'
@@ -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.hour
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
- "x-cos-security-token": x_cos_security_token,
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.from_now }
57
- cookies.signed_or_encrypted[:we_unionid] = { value: access_info['unionid'], expires: self.class.oauth2_cookie_duration.from_now }
58
- cookies.signed_or_encrypted[:we_access_token] = { value: access_info['access_token'], expires: self.class.oauth2_cookie_duration.from_now }
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.from_now }
73
- cookies.signed_or_encrypted[:we_deviceid] = { value: userinfo['DeviceId'], expires: self.class.oauth2_cookie_duration.from_now }
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
@@ -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
@@ -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
@@ -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.13.3
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
- MIIEQDCCAqigAwIBAgIBATANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBplcmlj
15
- Lmd1b2N6L0RDPWdtYWlsL0RDPWNvbTAeFw0yMDA5MDIwNDUzMjFaFw0yMTA5MDIw
16
- NDUzMjFaMCUxIzAhBgNVBAMMGmVyaWMuZ3VvY3ovREM9Z21haWwvREM9Y29tMIIB
17
- ojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAwSfWr5RlUBlv9OuNgmxjPwhU
18
- 7eoT/m7K5h0PzUaue+dtno4WqjodoCPHF6r9hh8Ys0h1VAPu3sobH2gNaL18M0CY
19
- bmq+ik6LgH5tX2E6c2BmhMuURt2y1YvIwvx0dDOlEXll9J8ZVqGyo3Rm9AIblA3/
20
- w/V5VJGCj3XY6iipNkHHDlSWSYeD2mNr0wJW8EAUFFcyRddpotxR9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YyCRFPFX1KLtUpFuXi/1rZoMoSug2Lpr+GWqt7eZIwNoryjYMbuE/sOn
30
+ sANkOvLx8x4RMlmTFe+WkPiV9NasFqNn7EBSpjqQRWRlCuh6rMiYzzxNbbNvbRT4
31
+ WMhBf7eWRpr1TBXDr51E8RtA+LG6wZuJFnKWBisgKOmpUw79f7EvIQAGS3MEWk/g
32
+ fSvIf14zM5Dw0whGa/n60jgSc5yiW3/75GXt8608BK+bs5dViJ/3ofuIhqpOvvdp
33
+ 4Oiv2zIXsfUIGAIwHN5mLwAwHty1d0s8Kt0jtJAXDUODgTuXaBj/aOqTZUUgp8Kv
34
+ 6SoPdaa0LFPbkI2eiUN1xUPelsgKz0kyRBJtkMnSKFxcCxw7VHGRGFsw0ORZodQ3
35
+ ZM9IDtdMg8E/4ujwilV8HKmgU77vVN6vSMvxx8zQFSz9a6GbdpB4egPZ++peSk/Q
36
+ uaIJtOX6M4VC6u7eZfotARKyUy6EcoN2zNqEAQ==
37
37
  -----END CERTIFICATE-----
38
- date: 2021-06-18 00:00:00.000000000 Z
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.20
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