grape-slack-bot 1.6.2 → 1.6.4
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 +9 -6
- data/lib/slack_bot/interaction.rb +10 -39
- 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: d67c8a3223c22c71a6c65df3779ec80008a06534d389eefa56fb1758fd91f352
|
4
|
+
data.tar.gz: 1e220f3dc13b1dd5a0ade887bd13bd0e86612f08433897efd0a4cd84cb96c354
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a731d872905dcc3da371323195b7c3efae2a4fc92a0174453e64f2815b82117d7dbd54f5b29e60077bdb5ea55716e17fd4882de7fc559d2c601bc01d447ca83
|
7
|
+
data.tar.gz: bd4409a17bbbb6191d4fd424fdf6502a06b4283bdcc7890e33c0052caa45b2a6ff23bb6870107b8ec802fbffac19859ac51f6d211ebb59cc3473e8ccac37fa03
|
data/lib/slack_bot/command.rb
CHANGED
@@ -57,16 +57,19 @@ module SlackBot
|
|
57
57
|
view.send(view_name)
|
58
58
|
end
|
59
59
|
|
60
|
-
def open_modal(view_name, context: nil)
|
61
|
-
|
62
|
-
self.class.interaction_klass.open_modal(
|
63
|
-
trigger_id: params[:trigger_id],
|
64
|
-
channel_id: params[:channel_id],
|
60
|
+
def open_modal(view_name, context: nil, callback: nil)
|
61
|
+
callback ||= Callback.create(
|
65
62
|
class_name: self.class.name,
|
66
63
|
user: @current_user,
|
67
|
-
|
64
|
+
channel_id: params[:channel_id],
|
68
65
|
config: config
|
69
66
|
)
|
67
|
+
view_payload = render_view(view_name, context: context)
|
68
|
+
self.class.interaction_klass.open_modal(
|
69
|
+
callback: callback,
|
70
|
+
trigger_id: params[:trigger_id],
|
71
|
+
payload: view_payload
|
72
|
+
)
|
70
73
|
render_response
|
71
74
|
end
|
72
75
|
end
|
@@ -8,22 +8,7 @@ module SlackBot
|
|
8
8
|
|
9
9
|
include SlackBot::Concerns::ViewKlass
|
10
10
|
|
11
|
-
def self.open_modal(
|
12
|
-
trigger_id:,
|
13
|
-
payload:,
|
14
|
-
class_name:,
|
15
|
-
user:,
|
16
|
-
channel_id: nil,
|
17
|
-
config: nil
|
18
|
-
)
|
19
|
-
callback =
|
20
|
-
Callback.create(
|
21
|
-
class_name: class_name,
|
22
|
-
user: user,
|
23
|
-
channel_id: channel_id,
|
24
|
-
config: config
|
25
|
-
)
|
26
|
-
|
11
|
+
def self.open_modal(callback:, trigger_id:, payload:)
|
27
12
|
view = payload.merge({ type: "modal", callback_id: callback.id })
|
28
13
|
response =
|
29
14
|
SlackBot::ApiClient.new.views_open(trigger_id: trigger_id, view: view)
|
@@ -38,23 +23,7 @@ module SlackBot
|
|
38
23
|
SlackViewsReply.new(callback.id, view_id)
|
39
24
|
end
|
40
25
|
|
41
|
-
def self.update_modal(
|
42
|
-
callback_id: nil,
|
43
|
-
view_id:,
|
44
|
-
payload:,
|
45
|
-
class_name: nil,
|
46
|
-
user: nil,
|
47
|
-
channel_id: nil,
|
48
|
-
config: nil
|
49
|
-
)
|
50
|
-
callback = Callback.find_or_create(
|
51
|
-
id: callback_id,
|
52
|
-
class_name: class_name,
|
53
|
-
user: user,
|
54
|
-
channel_id: channel_id,
|
55
|
-
config: config
|
56
|
-
)
|
57
|
-
|
26
|
+
def self.update_modal(callback:, view_id:, payload:)
|
58
27
|
view = payload.merge({ type: "modal", callback_id: callback.id })
|
59
28
|
response =
|
60
29
|
SlackBot::ApiClient.new.views_update(view_id: view_id, view: view)
|
@@ -103,13 +72,16 @@ module SlackBot
|
|
103
72
|
end
|
104
73
|
|
105
74
|
def open_modal(view_name, context: nil)
|
75
|
+
self.callback ||= Callback.create(
|
76
|
+
class_name: self.class.name,
|
77
|
+
user: @current_user,
|
78
|
+
config: config
|
79
|
+
)
|
106
80
|
view_payload = render_view(view_name, context: context)
|
107
81
|
self.class.open_modal(
|
82
|
+
callback: callback,
|
108
83
|
trigger_id: payload["trigger_id"],
|
109
|
-
payload: view_payload
|
110
|
-
class_name: self.class.name,
|
111
|
-
user: current_user,
|
112
|
-
config: config
|
84
|
+
payload: view_payload
|
113
85
|
)
|
114
86
|
end
|
115
87
|
|
@@ -122,8 +94,7 @@ module SlackBot
|
|
122
94
|
self.class.update_modal(
|
123
95
|
view_id: view_id,
|
124
96
|
payload: payload,
|
125
|
-
|
126
|
-
config: config
|
97
|
+
callback: callback
|
127
98
|
)
|
128
99
|
end
|
129
100
|
|
data/lib/slack_bot.rb
CHANGED