chatops-controller 3.1.1 → 4.0.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8597b8cef3aa55e16d0ed7f906dafaa1a0bd696de64f242e0ea3c41198b3be1a
|
4
|
+
data.tar.gz: 596ace61f59f6839ed2da67f8567fbe2d0ef02782652a6824ec2e3d584b8b0c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca8640d6f9531fa1af6887a0725e3237e3d52d9837d19d1ccfe542e8216525cfb187d2b794314ce9e53e9794c460016d6a5b1f7058abe374ac8ccde50d11ca9b
|
7
|
+
data.tar.gz: d1a43adf71fb993fea5b2678dfc96029031c953053237c6bf3203569ef181a61f26708ebd0283868dae8684bb83c060c3457da0b7ce1077463d0e6c10651a316
|
data/lib/chatops/controller.rb
CHANGED
@@ -27,10 +27,7 @@ module Chatops
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def process(*args)
|
30
|
-
|
31
|
-
:user, :mention_slug, :method, :controller, :action, :params, :room_id)
|
32
|
-
|
33
|
-
scrubbed_params.each { |k, v| params[k] = v }
|
30
|
+
setup_params!
|
34
31
|
|
35
32
|
if params[:chatop].present?
|
36
33
|
params[:action] = params[:chatop]
|
@@ -40,7 +37,7 @@ module Chatops
|
|
40
37
|
end
|
41
38
|
end
|
42
39
|
|
43
|
-
super
|
40
|
+
super(*args)
|
44
41
|
rescue AbstractController::ActionNotFound
|
45
42
|
return jsonrpc_method_not_found
|
46
43
|
end
|
@@ -52,8 +49,27 @@ module Chatops
|
|
52
49
|
|
53
50
|
protected
|
54
51
|
|
52
|
+
def setup_params!
|
53
|
+
json_body.each do |key, value|
|
54
|
+
next if params.has_key? key
|
55
|
+
params[key] = value
|
56
|
+
end
|
57
|
+
|
58
|
+
@jsonrpc_params = params.delete(:params) if params.has_key? :params
|
59
|
+
|
60
|
+
self.params = params.permit(:action, :chatop, :controller, :id, :mention_slug, :method, :room_id, :user)
|
61
|
+
end
|
62
|
+
|
55
63
|
def jsonrpc_params
|
56
|
-
|
64
|
+
@jsonrpc_params ||= ActionController::Parameters.new
|
65
|
+
end
|
66
|
+
|
67
|
+
def json_body
|
68
|
+
hash = {}
|
69
|
+
if request.content_type =~ %r/\Aapplication\/json\Z/i
|
70
|
+
hash = ActiveSupport::JSON.decode(request.raw_post) || {}
|
71
|
+
end
|
72
|
+
hash.with_indifferent_access
|
57
73
|
end
|
58
74
|
|
59
75
|
# `options` supports any of the optional fields documented
|
@@ -50,14 +50,14 @@ module Chatops::Controller::TestCaseHelpers
|
|
50
50
|
|
51
51
|
named_params, command = extract_named_params(message)
|
52
52
|
|
53
|
-
matcher = matchers.find { |
|
53
|
+
matcher = matchers.find { |m| m["regex"].match(command) }
|
54
54
|
|
55
55
|
raise NoMatchingCommandRegex.new("No command matches '#{command}'") unless matcher
|
56
56
|
|
57
57
|
match_data = matcher["regex"].match(command)
|
58
58
|
jsonrpc_params = named_params.dup
|
59
59
|
matcher["params"].each do |param|
|
60
|
-
jsonrpc_params[param]
|
60
|
+
jsonrpc_params[param] ||= match_data[param.to_sym]
|
61
61
|
end
|
62
62
|
jsonrpc_params.merge!(user: user, room_id: room_id, mention_slug: user)
|
63
63
|
chatop matcher["name"].to_sym, jsonrpc_params
|
@@ -14,8 +14,8 @@ describe ActionController::Base, type: :controller do
|
|
14
14
|
chatop :wcid,
|
15
15
|
/(?:where can i deploy|wcid)(?: (?<app>\S+))?/,
|
16
16
|
"where can i deploy?" do
|
17
|
-
return jsonrpc_invalid_params("I need nope, sorry") if
|
18
|
-
jsonrpc_success "You can deploy #{
|
17
|
+
return jsonrpc_invalid_params("I need nope, sorry") if jsonrpc_params[:app] == "nope"
|
18
|
+
jsonrpc_success "You can deploy #{jsonrpc_params["app"]} just fine."
|
19
19
|
end
|
20
20
|
|
21
21
|
chatop :foobar,
|
@@ -35,7 +35,7 @@ describe ActionController::Base, type: :controller do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def ensure_app_given
|
38
|
-
return jsonrpc_invalid_params("I need an app, every time") unless
|
38
|
+
return jsonrpc_invalid_params("I need an app, every time") unless jsonrpc_params[:app].present?
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chatops-controller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Lavender
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-09-
|
13
|
+
date: 2018-09-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|