sinatra-slack 0.8.0 → 0.8.1
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
- data/lib/sinatra/slack.rb +12 -9
- data/lib/sinatra/slack/instance_helpers.rb +13 -5
- data/lib/sinatra/slack/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66dde3da3ae5d04be459e5acc55cc5069d7f48c6a96b6e4a544ae47370cba42f
|
4
|
+
data.tar.gz: 4f523cffb4780a06a9a53c7e717c91b61aef670350ab83657fed29fcf8dbed75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e1521ea66b1bf106f9ba8da4377bbae740ec0cdf9f969d80e949f56d29a53b0d2def83e786b3afb1d7f3cb2cffddd86c3384fad269ec37bdd763cb0a9d86102
|
7
|
+
data.tar.gz: 4bc88b2b3410bb1b1c15fdbb32102fdaea86accef830bfbc0a03301f7a3f8675eef2985013656483cc69146d018a7352078d7324bc3a241791d5269f2ffe65e8
|
data/lib/sinatra/slack.rb
CHANGED
@@ -24,6 +24,8 @@ module Sinatra
|
|
24
24
|
set_endpoint(path, quick_reply) do
|
25
25
|
signature = "#{command.command} #{command.text}"
|
26
26
|
command_pattern = self.class.get_pattern(signature)
|
27
|
+
raise 'Command not defined' unless command_pattern
|
28
|
+
|
27
29
|
request_params = command_pattern.params(signature).values
|
28
30
|
|
29
31
|
{
|
@@ -38,6 +40,8 @@ module Sinatra
|
|
38
40
|
def actions_endpoint(path, quick_reply: '')
|
39
41
|
set_endpoint(path, quick_reply) do
|
40
42
|
action_pattern = self.class.get_pattern(action.name)
|
43
|
+
raise 'Action not defined' unless action_pattern
|
44
|
+
|
41
45
|
request_params = action_pattern.params(action.name).values || []
|
42
46
|
request_params << action.value
|
43
47
|
|
@@ -88,19 +92,18 @@ module Sinatra
|
|
88
92
|
define_method("#{path}_options", &block)
|
89
93
|
|
90
94
|
settings.apost(path) do
|
91
|
-
|
95
|
+
handle_with_rescue do
|
96
|
+
halt 401, 'Invalid Headers' unless authorized?
|
92
97
|
|
93
|
-
|
94
|
-
|
98
|
+
get_options = self.class.instance_method "#{path}_options"
|
99
|
+
options = get_options.bind(self).call
|
95
100
|
|
96
|
-
|
101
|
+
halt 400 unless options
|
97
102
|
|
98
|
-
|
103
|
+
options[:quick_reply] = quick_reply
|
99
104
|
|
100
|
-
|
101
|
-
|
102
|
-
logger.error ex.full_message
|
103
|
-
channel.send(slack_error_notification)
|
105
|
+
handle_request(options)
|
106
|
+
end
|
104
107
|
end
|
105
108
|
end
|
106
109
|
end
|
@@ -35,16 +35,24 @@ module Sinatra
|
|
35
35
|
|
36
36
|
def handle_request(request_handler:, request_params:, quick_reply: '...')
|
37
37
|
EM.defer do
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
channel.send(slack_error_notification)
|
38
|
+
handle_with_rescue do
|
39
|
+
deferred_message = request_handler.bind(self).call(*request_params)
|
40
|
+
channel.send(deferred_message)
|
41
|
+
end
|
43
42
|
end
|
44
43
|
|
45
44
|
body quick_reply
|
46
45
|
end
|
47
46
|
|
47
|
+
def handle_with_rescue
|
48
|
+
return unless block_given?
|
49
|
+
|
50
|
+
yield
|
51
|
+
rescue StandardError => ex
|
52
|
+
logger.error ex.full_message
|
53
|
+
channel.send(slack_error_notification)
|
54
|
+
end
|
55
|
+
|
48
56
|
# Checks for Slack defined HTTP headers
|
49
57
|
# and computes the request signature (HMAC). If provided signature
|
50
58
|
# is the same as the computed one, the request is valid.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-slack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nuno Namorado
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async_sinatra
|