grape-slack-bot 1.5.3 → 1.5.4

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: f2b70d87297ad0f3b585dfacc7eb41b14e2c67d7134bc3771d00fa0117d9f312
4
- data.tar.gz: 67db6701d3bc301502ab605a0987eb5e47bdcef3561bde1527646d57c0afdae0
3
+ metadata.gz: b7ec90d89547fb9fddd4972b16caad8cb96cc4f2163f82eebc40747d2ca79c1f
4
+ data.tar.gz: bf2fa99739aa63e4e0e63425abde569021d1e0ec061f155c3e07e58b966f2115
5
5
  SHA512:
6
- metadata.gz: 304d11b6af4266b369fbfb780056956435e323a32d0acea59440c46add848a3acb9339129a6bc0c11c23b5f0b34c2151b9097a11eb8d856ab0a62a18c4719e6f
7
- data.tar.gz: 313680981ca8e1e0445ed3ea97955bf8ea3d9eba4b32b0fe30690c3917a619304d2aa389e839e5ed6d46737a51a2f68ec7ef735a193f72ddbbe131daf3b73836
6
+ metadata.gz: 94aed6e295eb7150315c9bcc40fe3be10d5de81b257178e5691918b5ff3832f21622655b779c9ab6fcfd3aa4a9377870da16b91c6f9e69fc74d443f034e83b10
7
+ data.tar.gz: 5857289c58cb8bec70b25067848c623e0c60b5450562efa1ba48859b59271b0a10b08a807e662c1bfdfdabfd48e952be60f290f3395af01dd34b6e7925fced8f
@@ -4,8 +4,7 @@ module SlackBot
4
4
  define_singleton_method(:view_klass) { klass }
5
5
  end
6
6
 
7
- attr_reader :current_user, :params, :config
8
- attr_accessor :callback, :metadata
7
+ attr_reader :current_user, :params, :config, :callback, :metadata
9
8
  def initialize(current_user: nil, params: nil, callback: nil, config: nil)
10
9
  @current_user = current_user
11
10
  @params = params
@@ -19,6 +18,14 @@ module SlackBot
19
18
 
20
19
  private
21
20
 
21
+ def callback=(callback)
22
+ @callback = callback
23
+ end
24
+
25
+ def metadata=(metadata)
26
+ @metadata = metadata
27
+ end
28
+
22
29
  def event_type
23
30
  params["event"]["type"]
24
31
  end
@@ -8,12 +8,12 @@ module SlackBot
8
8
  base.use ActionDispatch::RemoteIp
9
9
  base.helpers do
10
10
  def fetch_team_id
11
- params.dig("team_id") || params.dig("team", "id")
11
+ params.dig("team_id") || params.dig("team", "id") || params.dig("payload", "user", "team_id")
12
12
  end
13
13
 
14
14
  def fetch_user_id
15
15
  params.dig("user_id") || params.dig("user", "id") ||
16
- params.dig("event", "user")
16
+ params.dig("event", "user") || params.dig("payload", "user", "id")
17
17
  end
18
18
 
19
19
  def verify_slack_signature!
@@ -20,6 +20,12 @@ module SlackBot
20
20
  @context = context.with_indifferent_access if context.is_a?(Hash)
21
21
  end
22
22
 
23
+ def method_missing(method_name, *args, &block)
24
+ return @context[method_name.to_sym] if @context.key?(method_name.to_sym)
25
+
26
+ super
27
+ end
28
+
23
29
  def text_modal
24
30
  {
25
31
  title: {
@@ -34,20 +40,20 @@ module SlackBot
34
40
 
35
41
  private
36
42
 
37
- def current_date
38
- Date.current
39
- end
40
-
41
43
  def divider_block
42
44
  { type: "divider" }
43
45
  end
44
46
 
47
+ def current_date
48
+ Date.current
49
+ end
50
+
45
51
  def command
46
52
  params[:command]
47
53
  end
48
54
 
49
55
  def paginate(cursor)
50
- SlackBot::Pager.new(cursor, args: args)
56
+ self.class.pager_klass.new(cursor, args: args)
51
57
  end
52
58
  end
53
59
  end
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.5.3'.freeze
25
+ VERSION = '1.5.4'.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.5.3
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Makarov