wechat 0.14.0 → 0.15.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: 90aad3955d68b49a3eaf8774fdc247a6f0f8c5e7887b3abde7249fd4f4d6c64b
4
- data.tar.gz: 7c6ca0a6bd601a5527c8e99db9ddc687a4a057131dd3d6e1556ae0677781ddcd
3
+ metadata.gz: fce405bc512324a4f862cab6f746833ec387b6a5eed1fc9f720a9bda16e309da
4
+ data.tar.gz: 932fba467df6c8f357e713bd63e6a5537436fe8e34fc1a9c50f0c9d5010a6707
5
5
  SHA512:
6
- metadata.gz: 8e83f65806db0a976da02ed4aa1bb74554af42ee0e1e9c5c9c484ec23f46a34d268dbe1396fcd2e0d6b25e70f0d99731a206ce6468a6889bc3ae523997947564
7
- data.tar.gz: a04c6ee54cf2280e2a45bc0eea3ba2d6a1d8e45e5d02e443e2c36b524da09ec96a5b4645b7e3ecfa3c9e1754ca31a40a8683c780d4e9fcd93f417be6da70e247
6
+ metadata.gz: 6a2f9892ae32dd7c86f9e4f80d026cef254f738dbb93cab3d8ae3a411307144eb767077e0b781652d2fcc768d2a51cb504e3134bc0c4e0efc4b30066b78152ce
7
+ data.tar.gz: 2fba8e299e8cb2614852d587bd84287463a57ae91248dcc8d729ee0539038160ff2ec3f469c4ffad9e3906ae87c2b12020bc6c47501b12127593202da2483322
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.15.0 (released at 2021-12-21)
4
+
5
+ * Add wechat message json format support, by @younthu #306
6
+ * Support Rails 7 in this version.
7
+ * Fix wechat command-line 1st attempt bug #307
8
+
3
9
  ## v0.14.0 (released at 2021-09-15)
4
10
 
5
11
  * Add beta support for Conversation archive in WeCom, discuss at #303
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://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)
1
+ WeChat [![Gem Version](https://badge.fury.io/rb/wechat.svg)](https://rubygems.org/gems/wechat) [![Build Status](https://mixtint.semaphoreci.com/badges/wechat/branches/main.svg?style=shields)](https://mixtint.semaphoreci.com/projects/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)
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://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)
1
+ WeChat [![Gem Version](https://badge.fury.io/rb/wechat.svg)](https://rubygems.org/gems/wechat) [![Build Status](https://mixtint.semaphoreci.com/badges/wechat/branches/main.svg?style=shields)](https://mixtint.semaphoreci.com/projects/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)
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_support/core_ext/object/blank'
4
+
3
5
  module Wechat
4
6
  module ApiLoader
5
7
  def self.with(options)
@@ -42,11 +44,11 @@ module Wechat
42
44
  configs = config_from_file || config_from_environment
43
45
  configs.merge!(config_from_db)
44
46
 
45
- configs.symbolize_keys!
47
+ configs.transform_keys! { |key| key.to_sym rescue key }
46
48
  configs.each do |key, cfg|
47
49
  raise "wrong wechat configuration format for #{key}" unless cfg.is_a?(Hash)
48
50
 
49
- cfg.symbolize_keys!
51
+ cfg.transform_keys! { |key| key.to_sym rescue key }
50
52
  end
51
53
 
52
54
  if defined?(::Rails)
@@ -60,7 +62,7 @@ module Wechat
60
62
  configs.each do |_, cfg|
61
63
  cfg[:timeout] ||= 20
62
64
  cfg[:qcloud_token_lifespan] ||= 7200
63
- cfg[:have_session_class] = class_exists?('WechatSession')
65
+ cfg[:have_session_class] ||= class_exists?('WechatSession')
64
66
  cfg[:oauth2_cookie_duration] ||= 3600 # 1 hour
65
67
  end
66
68
 
@@ -84,6 +86,7 @@ module Wechat
84
86
  config_file = ENV['WECHAT_CONF_FILE'] || Rails.root.join('config', 'wechat.yml')
85
87
  resolve_config_file(config_file, Rails.env.to_s)
86
88
  else
89
+ require 'erb'
87
90
  rails_config_file = ENV['WECHAT_CONF_FILE'] || File.join(Dir.getwd, 'config', 'wechat.yml')
88
91
  application_config_file = File.join(Dir.getwd, 'config', 'application.yml')
89
92
  home_config_file = File.join(Dir.home, '.wechat.yml')
@@ -187,7 +187,7 @@ module Wechat
187
187
  end
188
188
 
189
189
  def create
190
- request_msg = Wechat::Message.from_hash(post_xml)
190
+ request_msg = Wechat::Message.from_hash(post_body)
191
191
  response_msg = run_responder(request_msg)
192
192
 
193
193
  if response_msg.respond_to? :to_xml
@@ -229,6 +229,24 @@ module Wechat
229
229
  msg_encrypt)
230
230
  end
231
231
 
232
+ def post_body
233
+ if request.media_type == 'application/json'
234
+ data_hash = params
235
+
236
+ if @we_encrypt_mode && data['Encrypt'].present?
237
+ content, @we_app_id = unpack(decrypt(Base64.decode64(data['Encrypt']), @we_encoding_aes_key))
238
+ data_hash = content
239
+ end
240
+
241
+ data_hash = data_hash.to_unsafe_hash if data_hash.instance_of?(ActionController::Parameters)
242
+ HashWithIndifferentAccess.new(data_hash).tap do |msg|
243
+ msg[:Event]&.downcase!
244
+ end
245
+ else
246
+ post_xml
247
+ end
248
+ end
249
+
232
250
  def post_xml
233
251
  data = request_content
234
252
 
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.14.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Skinnyworm
@@ -35,7 +35,7 @@ cert_chain:
35
35
  ZM9IDtdMg8E/4ujwilV8HKmgU77vVN6vSMvxx8zQFSz9a6GbdpB4egPZ++peSk/Q
36
36
  uaIJtOX6M4VC6u7eZfotARKyUy6EcoN2zNqEAQ==
37
37
  -----END CERTIFICATE-----
38
- date: 2021-09-15 00:00:00.000000000 Z
38
+ date: 2021-12-21 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: activesupport
@@ -44,9 +44,6 @@ dependencies:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: '6.0'
47
- - - "<"
48
- - !ruby/object:Gem::Version
49
- version: '7'
50
47
  type: :runtime
51
48
  prerelease: false
52
49
  version_requirements: !ruby/object:Gem::Requirement
@@ -54,9 +51,6 @@ dependencies:
54
51
  - - ">="
55
52
  - !ruby/object:Gem::Version
56
53
  version: '6.0'
57
- - - "<"
58
- - !ruby/object:Gem::Version
59
- version: '7'
60
54
  - !ruby/object:Gem::Dependency
61
55
  name: http
62
56
  requirement: !ruby/object:Gem::Requirement
@@ -153,14 +147,14 @@ dependencies:
153
147
  requirements:
154
148
  - - ">="
155
149
  - !ruby/object:Gem::Version
156
- version: '6.0'
150
+ version: 7.0.0
157
151
  type: :development
158
152
  prerelease: false
159
153
  version_requirements: !ruby/object:Gem::Requirement
160
154
  requirements:
161
155
  - - ">="
162
156
  - !ruby/object:Gem::Version
163
- version: '6.0'
157
+ version: 7.0.0
164
158
  - !ruby/object:Gem::Dependency
165
159
  name: rspec-rails
166
160
  requirement: !ruby/object:Gem::Requirement
@@ -242,7 +236,12 @@ files:
242
236
  homepage: https://github.com/Eric-Guo/wechat
243
237
  licenses:
244
238
  - MIT
245
- metadata: {}
239
+ metadata:
240
+ bug_tracker_uri: https://github.com/Eric-Guo/wechat/issues
241
+ changelog_uri: https://github.com/Eric-Guo/wechat/releases
242
+ documentation_uri: https://github.com/Eric-Guo/wechat/tree/v0.15.0#readme
243
+ source_code_uri: https://github.com/Eric-Guo/wechat/tree/v0.15.0
244
+ rubygems_mfa_required: 'true'
246
245
  post_install_message:
247
246
  rdoc_options: []
248
247
  require_paths:
@@ -256,9 +255,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
255
  requirements:
257
256
  - - ">="
258
257
  - !ruby/object:Gem::Version
259
- version: '0'
258
+ version: 1.8.11
260
259
  requirements: []
261
- rubygems_version: 3.2.27
260
+ rubygems_version: 3.2.33
262
261
  signing_key:
263
262
  specification_version: 4
264
263
  summary: DSL for wechat message handling and API
metadata.gz.sig CHANGED
Binary file