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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d1e2ef3d6febf5115a2d8276cb673f6ed5559ee9a3db93116bd7171bade5bf0
4
- data.tar.gz: ec20059fae8d6c3198ac5d989d8a61913a780f3b45c4345c7b744d46a31e50f7
3
+ metadata.gz: c4cd56999a5a9b67729fe61e5f95a79f6a0ab89aeafaa43f7537b4501fe6b81a
4
+ data.tar.gz: 867a61f2c1f28c82f1c0d3e5bef97ecf6602176c7d89fe221d57c8161048b628
5
5
  SHA512:
6
- metadata.gz: 2be7aab3a38801d1b8e8f1581badb224a9e3767f638805c69d1a7efcf59ad8e8be75589a49c636c2fe0793591f431063ea824688fbf8cce1647020151bc970c1
7
- data.tar.gz: 36821a7bc17bf1641c3d0a8da65497ec46a35713b7b71abed8a95c38c7cff276d501483c8d378c56105bd60669b421d31ae879f0de15f09c4d42143de2d2f6dc
6
+ metadata.gz: 1bed9b092db2eaa13610c7e892663d2d5313321d49dc5e097b7278a1d12f9e47d812e101f153892b8b3d7a71cb5141a2fc189fd5689f54cbcd36ae747e7510f3
7
+ data.tar.gz: bce0459566f928181c2bef05062109d11f2633717c06e60841b2001c003bf0d317b92f234ed1eb7b0fdba0424120fd7fe6886f7753cedc3a2f784c3cd03a78c1
@@ -46,7 +46,7 @@ module SlackBot
46
46
 
47
47
  private
48
48
 
49
- def open_modal(view_name, context: nil)
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
- payload = view.send(view_name)
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: payload,
67
+ payload: view_payload,
64
68
  config: config
65
69
  )
66
70
  render_response
@@ -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
- args = callback.args
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
@@ -22,5 +22,5 @@ require 'slack_bot/pager'
22
22
  require 'slack_bot/grape_extension'
23
23
 
24
24
  module SlackBot
25
- VERSION = '1.6.0'.freeze
25
+ VERSION = '1.6.1'.freeze
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-slack-bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Makarov