grape-slack-bot 1.6.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/slack_bot/command.rb +7 -3
- data/lib/slack_bot/event.rb +12 -4
- data/lib/slack_bot/interaction.rb +24 -11
- data/lib/slack_bot.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4cd56999a5a9b67729fe61e5f95a79f6a0ab89aeafaa43f7537b4501fe6b81a
|
4
|
+
data.tar.gz: 867a61f2c1f28c82f1c0d3e5bef97ecf6602176c7d89fe221d57c8161048b628
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bed9b092db2eaa13610c7e892663d2d5313321d49dc5e097b7278a1d12f9e47d812e101f153892b8b3d7a71cb5141a2fc189fd5689f54cbcd36ae747e7510f3
|
7
|
+
data.tar.gz: bce0459566f928181c2bef05062109d11f2633717c06e60841b2001c003bf0d317b92f234ed1eb7b0fdba0424120fd7fe6886f7753cedc3a2f784c3cd03a78c1
|
data/lib/slack_bot/command.rb
CHANGED
@@ -46,7 +46,7 @@ module SlackBot
|
|
46
46
|
|
47
47
|
private
|
48
48
|
|
49
|
-
def
|
49
|
+
def render_view(view_name, context: nil)
|
50
50
|
view = self.class.view_klass.new(
|
51
51
|
args: args,
|
52
52
|
current_user: @current_user,
|
@@ -54,13 +54,17 @@ module SlackBot
|
|
54
54
|
context: context,
|
55
55
|
config: config
|
56
56
|
)
|
57
|
-
|
57
|
+
view.send(view_name)
|
58
|
+
end
|
59
|
+
|
60
|
+
def open_modal(view_name, context: nil)
|
61
|
+
view_payload = render_view(view_name, context: context)
|
58
62
|
self.class.interaction_klass.open_modal(
|
59
63
|
trigger_id: params[:trigger_id],
|
60
64
|
channel_id: params[:channel_id],
|
61
65
|
class_name: self.class.name,
|
62
66
|
user: @current_user,
|
63
|
-
payload:
|
67
|
+
payload: view_payload,
|
64
68
|
config: config
|
65
69
|
)
|
66
70
|
render_response
|
data/lib/slack_bot/event.rb
CHANGED
@@ -32,12 +32,20 @@ module SlackBot
|
|
32
32
|
params["event"]["type"]
|
33
33
|
end
|
34
34
|
|
35
|
+
def render_view(view_name, context: nil)
|
36
|
+
view = self.class.view_klass.new(
|
37
|
+
args: callback&.args,
|
38
|
+
current_user: current_user,
|
39
|
+
params: params,
|
40
|
+
context: context,
|
41
|
+
config: config
|
42
|
+
)
|
43
|
+
view.send(view_name)
|
44
|
+
end
|
45
|
+
|
35
46
|
def publish_view(view_method_name, context: nil)
|
36
47
|
user_id = params["event"]["user"]
|
37
|
-
view =
|
38
|
-
self.class.view_klass
|
39
|
-
.new(current_user: current_user, params: params, context: context)
|
40
|
-
.send(view_method_name)
|
48
|
+
view = render_view(view_method_name, context: context)
|
41
49
|
view = view.merge(callback_id: callback.id) if callback.present?
|
42
50
|
view = view.merge(private_metadata: metadata) if metadata.present?
|
43
51
|
response =
|
@@ -13,7 +13,7 @@ module SlackBot
|
|
13
13
|
payload:,
|
14
14
|
class_name:,
|
15
15
|
user:,
|
16
|
-
channel_id
|
16
|
+
channel_id: nil,
|
17
17
|
config: nil
|
18
18
|
)
|
19
19
|
callback =
|
@@ -91,20 +91,33 @@ module SlackBot
|
|
91
91
|
payload["actions"]
|
92
92
|
end
|
93
93
|
|
94
|
+
def render_view(view_name, context: nil)
|
95
|
+
view = self.class.view_klass.new(
|
96
|
+
args: callback&.args,
|
97
|
+
current_user: current_user,
|
98
|
+
params: params,
|
99
|
+
context: context,
|
100
|
+
config: config
|
101
|
+
)
|
102
|
+
view.send(view_name)
|
103
|
+
end
|
104
|
+
|
105
|
+
def open_modal(view_name, context: nil)
|
106
|
+
view_payload = render_view(view_name, context: context)
|
107
|
+
self.class.open_modal(
|
108
|
+
trigger_id: payload["trigger_id"],
|
109
|
+
payload: view_payload,
|
110
|
+
class_name: self.class.name,
|
111
|
+
user: current_user,
|
112
|
+
config: config
|
113
|
+
)
|
114
|
+
end
|
115
|
+
|
94
116
|
def update_modal(view_name, context: nil)
|
95
117
|
return if callback.blank?
|
96
118
|
|
97
119
|
view_id = payload["view"]["id"]
|
98
|
-
|
99
|
-
view =
|
100
|
-
self.class.view_klass.new(
|
101
|
-
args: args,
|
102
|
-
current_user: current_user,
|
103
|
-
params: params,
|
104
|
-
context: context,
|
105
|
-
config: config
|
106
|
-
)
|
107
|
-
payload = view.send(view_name)
|
120
|
+
payload = render_view(view_name, context: context)
|
108
121
|
|
109
122
|
self.class.update_modal(
|
110
123
|
view_id: view_id,
|
data/lib/slack_bot.rb
CHANGED