mos-eisley 0.2.1 → 0.3.0

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
  SHA1:
3
- metadata.gz: d5529becb768cce998bee34788e440fe76d5b11e
4
- data.tar.gz: 5132679c903e99480446f9fcef9a17a3af9861bc
3
+ metadata.gz: f4690494a37ed6dcce4ee882424dbd867a851964
4
+ data.tar.gz: bad0f837d3de124d2dd0e450f3918c409ae59da2
5
5
  SHA512:
6
- metadata.gz: ab259e18673bbd68f4af2800137eab81355fee483cfc456d33f8139a22081f53786d0122750603d2065af69ee86380a93cfce911bb8fed3fa323a9313bea09ac
7
- data.tar.gz: 8ede1448e9e902b94da8f73c7f78df62d396c0293661f35de05ccfe92f7e008dad5fee43c7de0b2e713b14d63dd203e3c78002d8ee0a565b9c832e007e0dff79
6
+ metadata.gz: 655c79f4948cf2246b2ecf14c245ae28c4977b0a26bfebed0ab4ae863461a8bde1c50667490d8c3a4a84657661902731920b43954163de82e7e49916b45e30a7
7
+ data.tar.gz: 1ce19780922c1cffcfce09163c4783bd84d10ca1de8ea28639b286be1f0ecb3ff677a9db32e1e225c53686e93e765e9409c6e9f740b7087e20b16490c2ff3da8
@@ -21,6 +21,14 @@ module MosEisley
21
21
  post_to_slack('chat.postEphemeral', msg)
22
22
  end
23
23
 
24
+ def self.update(msg)
25
+ post_to_slack('chat.update', msg)
26
+ end
27
+
28
+ def self.dialog_open(msg)
29
+ post_to_slack('dialog.open', msg)
30
+ end
31
+
24
32
  private
25
33
 
26
34
  def self.post_to_slack(method, data = nil, abort_on_err = false, &block)
@@ -1,5 +1,5 @@
1
1
  module MosEisley
2
2
 
3
- VERSION = '0.2.1'.freeze
3
+ VERSION = '0.3.0'.freeze
4
4
 
5
5
  end
data/lib/s3po/action.rb CHANGED
@@ -1,11 +1,35 @@
1
1
  module MosEisley
2
2
  module S3PO
3
3
  class Action
4
- attr_reader :event
5
- attr_reader :original_message
4
+ attr_reader :event, :type, :original_message
5
+
6
+ def self.add_pending(act)
7
+ pending_gc
8
+ @pending ||= {}
9
+ @pending[act.callback_id] = act
10
+ end
11
+
12
+ def self.pending
13
+ pending_gc
14
+ @pending
15
+ end
16
+
17
+ def self.pending_gc
18
+ return unless @pending
19
+ return if @gc_running
20
+ @gc_running = true
21
+ delkeys = []
22
+ @pending.each do |id, act|
23
+ ts = Time.at(act.action_ts.to_f)
24
+ delkeys << id if Time.now - ts > 60 * 30
25
+ end
26
+ delkeys.each { |k| @pending.delete(k) }
27
+ @gc_running = false
28
+ end
6
29
 
7
30
  def initialize(e)
8
31
  @event = e
32
+ @type = @event[:type].to_sym
9
33
  if e[:original_message]
10
34
  @original_message = Message.new(e[:original_message])
11
35
  end
@@ -31,6 +55,10 @@ module MosEisley
31
55
  event[:message_ts]
32
56
  end
33
57
 
58
+ def action_ts
59
+ event[:action_ts]
60
+ end
61
+
34
62
  def attachment_id
35
63
  event[:attachment_id].to_i
36
64
  end
@@ -39,6 +67,18 @@ module MosEisley
39
67
  event[:response_url]
40
68
  end
41
69
 
70
+ def trigger_id
71
+ event[:trigger_id]
72
+ end
73
+
74
+ def submission
75
+ event[:submission]
76
+ end
77
+
78
+ def original_event
79
+ Action.pending[callback_id]
80
+ end
81
+
42
82
  def message_age
43
83
  Time.now.to_i - message_ts.to_i
44
84
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mos-eisley
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken J.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-20 00:00:00.000000000 Z
11
+ date: 2018-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-http-request
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  requirements: []
114
114
  rubyforge_project:
115
- rubygems_version: 2.6.12
115
+ rubygems_version: 2.4.8
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: A Ruby based multi-purpose Slack app server