pubnub 5.3.4 → 5.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pubnub (5.3.4)
4
+ pubnub (5.4.0)
5
5
  addressable (>= 2.0.0)
6
- concurrent-ruby (~> 1.1.5)
7
- concurrent-ruby-edge (~> 0.5.0)
6
+ concurrent-ruby (~> 1.3.4)
7
+ concurrent-ruby-edge (~> 0.7.1)
8
8
  dry-validation (~> 1.0)
9
9
  httpclient (~> 2.8, >= 2.8.3)
10
10
  json (>= 2.2.0, < 3)
@@ -13,62 +13,65 @@ PATH
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- addressable (2.8.6)
17
- public_suffix (>= 2.0.2, < 6.0)
16
+ addressable (2.8.7)
17
+ public_suffix (>= 2.0.2, < 7.0)
18
18
  ast (2.4.2)
19
19
  awesome_print (1.9.2)
20
- bigdecimal (3.1.6)
21
- binding_of_caller (1.0.0)
22
- debug_inspector (>= 0.0.1)
23
- builder (3.2.4)
20
+ base64 (0.2.0)
21
+ bigdecimal (3.1.8)
22
+ binding_of_caller (1.0.1)
23
+ debug_inspector (>= 1.2.0)
24
+ builder (3.3.0)
24
25
  codacy-coverage (2.2.1)
25
26
  simplecov
26
27
  coderay (1.1.3)
27
- concurrent-ruby (1.1.10)
28
- concurrent-ruby-edge (0.5.0)
29
- concurrent-ruby (~> 1.1.5)
30
- crack (0.4.5)
28
+ concurrent-ruby (1.3.4)
29
+ concurrent-ruby-edge (0.7.1)
30
+ concurrent-ruby (~> 1.3)
31
+ crack (1.0.0)
32
+ bigdecimal
31
33
  rexml
32
- cucumber (9.1.2)
33
- builder (~> 3.2, >= 3.2.4)
34
- cucumber-ci-environment (~> 9.2, >= 9.2.0)
35
- cucumber-core (~> 12.0)
34
+ cucumber (9.2.0)
35
+ builder (~> 3.2)
36
+ cucumber-ci-environment (> 9, < 11)
37
+ cucumber-core (> 13, < 14)
36
38
  cucumber-cucumber-expressions (~> 17.0)
37
- cucumber-gherkin (> 24, < 27)
39
+ cucumber-gherkin (> 24, < 28)
38
40
  cucumber-html-formatter (> 20.3, < 22)
39
41
  cucumber-messages (> 19, < 25)
40
42
  diff-lcs (~> 1.5)
41
- mini_mime (~> 1.1, >= 1.1.5)
42
- multi_test (~> 1.1, >= 1.1.0)
43
- sys-uname (~> 1.2, >= 1.2.3)
44
- cucumber-ci-environment (9.2.0)
45
- cucumber-core (12.0.0)
46
- cucumber-gherkin (>= 25, < 27)
43
+ mini_mime (~> 1.1)
44
+ multi_test (~> 1.1)
45
+ sys-uname (~> 1.2)
46
+ cucumber-ci-environment (10.0.1)
47
+ cucumber-core (13.0.3)
48
+ cucumber-gherkin (>= 27, < 28)
47
49
  cucumber-messages (>= 20, < 23)
48
- cucumber-tag-expressions (~> 5.0, >= 5.0.4)
49
- cucumber-cucumber-expressions (17.0.1)
50
- cucumber-gherkin (26.2.0)
51
- cucumber-messages (>= 19.1.4, < 22.1)
52
- cucumber-html-formatter (21.2.0)
53
- cucumber-messages (> 19, < 25)
50
+ cucumber-tag-expressions (> 5, < 7)
51
+ cucumber-cucumber-expressions (17.1.0)
52
+ bigdecimal
53
+ cucumber-gherkin (27.0.0)
54
+ cucumber-messages (>= 19.1.4, < 23)
55
+ cucumber-html-formatter (21.7.0)
56
+ cucumber-messages (> 19, < 27)
54
57
  cucumber-messages (22.0.0)
55
- cucumber-tag-expressions (5.0.6)
58
+ cucumber-tag-expressions (6.1.0)
56
59
  debug_inspector (1.2.0)
57
- diff-lcs (1.5.0)
58
- docile (1.4.0)
59
- dry-configurable (1.1.0)
60
+ diff-lcs (1.5.1)
61
+ docile (1.4.1)
62
+ dry-configurable (1.2.0)
60
63
  dry-core (~> 1.0, < 2)
61
64
  zeitwerk (~> 2.6)
62
65
  dry-core (1.0.1)
63
66
  concurrent-ruby (~> 1.0)
64
67
  zeitwerk (~> 2.6)
65
- dry-inflector (1.0.0)
68
+ dry-inflector (1.1.0)
66
69
  dry-initializer (3.1.1)
67
70
  dry-logic (1.5.0)
68
71
  concurrent-ruby (~> 1.0)
69
72
  dry-core (~> 1.0, < 2)
70
73
  zeitwerk (~> 2.6)
71
- dry-schema (1.13.3)
74
+ dry-schema (1.13.4)
72
75
  concurrent-ruby (~> 1.0)
73
76
  dry-configurable (~> 1.0, >= 1.0.1)
74
77
  dry-core (~> 1.0, < 2)
@@ -89,17 +92,18 @@ GEM
89
92
  dry-initializer (~> 3.0)
90
93
  dry-schema (>= 1.12, < 2)
91
94
  zeitwerk (~> 2.6)
92
- ffi (1.16.3)
93
- hashdiff (1.1.0)
95
+ ffi (1.17.0)
96
+ hashdiff (1.1.1)
94
97
  httpclient (2.8.3)
95
98
  interception (0.5)
96
- json (2.7.1)
99
+ json (2.7.2)
97
100
  language_server-protocol (3.17.0.3)
98
- method_source (1.0.0)
101
+ lint_roller (1.1.0)
102
+ method_source (1.1.0)
99
103
  mini_mime (1.1.5)
100
104
  multi_test (1.1.0)
101
- parallel (1.24.0)
102
- parser (3.3.0.5)
105
+ parallel (1.26.3)
106
+ parser (3.3.5.0)
103
107
  ast (~> 2.4.1)
104
108
  racc
105
109
  pry (0.14.2)
@@ -111,57 +115,72 @@ GEM
111
115
  pry-stack_explorer (0.6.1)
112
116
  binding_of_caller (~> 1.0)
113
117
  pry (~> 0.13)
114
- public_suffix (5.0.4)
115
- racc (1.7.3)
118
+ public_suffix (6.0.1)
119
+ racc (1.8.1)
116
120
  rainbow (3.1.1)
117
- regexp_parser (2.9.0)
118
- rexml (3.2.6)
119
- rr (3.1.0)
120
- rspec (3.12.0)
121
- rspec-core (~> 3.12.0)
122
- rspec-expectations (~> 3.12.0)
123
- rspec-mocks (~> 3.12.0)
124
- rspec-core (3.12.2)
125
- rspec-support (~> 3.12.0)
126
- rspec-expectations (3.12.3)
121
+ regexp_parser (2.9.2)
122
+ rexml (3.3.8)
123
+ rr (3.1.1)
124
+ rspec (3.13.0)
125
+ rspec-core (~> 3.13.0)
126
+ rspec-expectations (~> 3.13.0)
127
+ rspec-mocks (~> 3.13.0)
128
+ rspec-core (3.13.1)
129
+ rspec-support (~> 3.13.0)
130
+ rspec-expectations (3.13.3)
127
131
  diff-lcs (>= 1.2.0, < 2.0)
128
- rspec-support (~> 3.12.0)
129
- rspec-mocks (3.12.6)
132
+ rspec-support (~> 3.13.0)
133
+ rspec-mocks (3.13.2)
130
134
  diff-lcs (>= 1.2.0, < 2.0)
131
- rspec-support (~> 3.12.0)
135
+ rspec-support (~> 3.13.0)
132
136
  rspec-retry (0.6.2)
133
137
  rspec-core (> 3.3)
134
- rspec-support (3.12.1)
135
- rubocop (1.60.2)
138
+ rspec-support (3.13.1)
139
+ rubocop (1.66.1)
136
140
  json (~> 2.3)
137
141
  language_server-protocol (>= 3.17.0)
138
142
  parallel (~> 1.10)
139
143
  parser (>= 3.3.0.2)
140
144
  rainbow (>= 2.2.2, < 4.0)
141
- regexp_parser (>= 1.8, < 3.0)
142
- rexml (>= 3.2.5, < 4.0)
143
- rubocop-ast (>= 1.30.0, < 2.0)
145
+ regexp_parser (>= 2.4, < 3.0)
146
+ rubocop-ast (>= 1.32.2, < 2.0)
144
147
  ruby-progressbar (~> 1.7)
145
148
  unicode-display_width (>= 2.4.0, < 3.0)
146
- rubocop-ast (1.30.0)
147
- parser (>= 3.2.1.0)
149
+ rubocop-ast (1.32.3)
150
+ parser (>= 3.3.1.0)
151
+ rubocop-performance (1.23.0)
152
+ rubocop (>= 1.48.1, < 2.0)
153
+ rubocop-ast (>= 1.31.1, < 2.0)
148
154
  ruby-progressbar (1.13.0)
149
155
  simplecov (0.22.0)
150
156
  docile (~> 1.1)
151
157
  simplecov-html (~> 0.11)
152
158
  simplecov_json_formatter (~> 0.1)
153
- simplecov-html (0.12.3)
159
+ simplecov-html (0.13.1)
154
160
  simplecov_json_formatter (0.1.4)
155
- sys-uname (1.2.3)
161
+ standard (1.41.1)
162
+ language_server-protocol (~> 3.17.0.2)
163
+ lint_roller (~> 1.0)
164
+ rubocop (~> 1.66.0)
165
+ standard-custom (~> 1.0.0)
166
+ standard-performance (~> 1.5)
167
+ standard-custom (1.0.2)
168
+ lint_roller (~> 1.0)
169
+ rubocop (~> 1.50)
170
+ standard-performance (1.6.0)
171
+ lint_roller (~> 1.1)
172
+ rubocop-performance (~> 1.23.0)
173
+ sys-uname (1.3.0)
156
174
  ffi (~> 1.1)
157
175
  timers (4.3.5)
158
- unicode-display_width (2.5.0)
159
- vcr (6.2.0)
160
- webmock (3.19.1)
176
+ unicode-display_width (2.6.0)
177
+ vcr (6.3.1)
178
+ base64
179
+ webmock (3.24.0)
161
180
  addressable (>= 2.8.0)
162
181
  crack (>= 0.3.2)
163
182
  hashdiff (>= 0.4.0, < 2.0.0)
164
- zeitwerk (2.6.12)
183
+ zeitwerk (2.6.18)
165
184
 
166
185
  PLATFORMS
167
186
  ruby
@@ -180,6 +199,7 @@ DEPENDENCIES
180
199
  rspec-retry
181
200
  rubocop
182
201
  simplecov (>= 0.21.2)
202
+ standard
183
203
  vcr
184
204
  webmock
185
205
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.3.4
1
+ 5.4.0
@@ -4,14 +4,16 @@ module Pubnub
4
4
  class Client
5
5
  # Module that holds generator for all events
6
6
  module Events
7
- EVENTS = %w[publish subscribe presence leave history here_now audit grant grant_token revoke_token delete_messages
8
- revoke time heartbeat where_now set_state state channel_registration message_counts signal
9
- add_message_action get_message_actions remove_message_action
10
- add_channels_to_push list_push_provisions remove_channels_from_push remove_device_from_push
11
- set_uuid_metadata set_channel_metadata remove_uuid_metadata remove_channel_metadata
12
- get_uuid_metadata get_all_uuid_metadata get_channel_metadata get_all_channels_metadata
13
- get_channel_members get_memberships set_channel_members set_memberships
14
- remove_memberships remove_channel_members].freeze
7
+ EVENTS = %w[publish subscribe presence leave history fetch_messages here_now audit grant
8
+ grant_token revoke_token delete_messages revoke time heartbeat where_now
9
+ set_state state channel_registration message_counts signal add_message_action
10
+ get_message_actions remove_message_action add_channels_to_push
11
+ list_push_provisions remove_channels_from_push remove_device_from_push
12
+ set_uuid_metadata set_channel_metadata remove_uuid_metadata
13
+ remove_channel_metadata get_uuid_metadata get_all_uuid_metadata
14
+ get_channel_metadata get_all_channels_metadata get_channel_members
15
+ get_memberships set_channel_members set_memberships remove_memberships
16
+ remove_channel_members].freeze
15
17
 
16
18
  EVENTS.each do |event_name|
17
19
  define_method event_name do |options = {}, &block|
data/lib/pubnub/client.rb CHANGED
@@ -1,85 +1,86 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'base64'
4
-
5
- require 'pubnub/error'
6
- require 'pubnub/uuid'
7
- require 'pubnub/formatter'
8
- require 'pubnub/constants'
9
- require 'pubnub/configuration'
10
- require 'pubnub/subscribe_callback'
11
-
12
- require 'pubnub/modules/crypto/module'
13
-
14
- require 'pubnub/schemas/envelope_schema'
15
-
16
- require 'pubnub/event'
17
- require 'pubnub/single_event'
18
- require 'pubnub/subscribe_event/callbacks'
19
- require 'pubnub/subscribe_event/formatter'
20
- require 'pubnub/subscribe_event/heartbeat'
21
- require 'pubnub/subscribe_event/adding'
22
- require 'pubnub/subscribe_event/removing'
23
- require 'pubnub/subscribe_event'
24
- require 'pubnub/pam'
25
- require 'pubnub/heart'
26
- require 'pubnub/subscriber'
27
- require 'pubnub/telemetry'
28
-
29
- require 'pubnub/envelope'
30
- require 'pubnub/error_envelope'
31
-
32
- require 'pubnub/client/events'
33
- require 'pubnub/client/paged_history'
34
- require 'pubnub/client/helpers'
35
- require 'pubnub/client/getters_setters'
36
-
37
- require 'pubnub/validators/get_message_actions'
38
- require 'pubnub/validators/add_message_action'
39
- require 'pubnub/validators/remove_message_action'
40
- require 'pubnub/validators/common_validator'
41
- require 'pubnub/validators/client'
42
- require 'pubnub/validators/audit'
43
- require 'pubnub/validators/channel_registration'
44
- require 'pubnub/validators/grant'
45
- require 'pubnub/validators/grant_token'
46
- require 'pubnub/validators/revoke_token'
47
- require 'pubnub/validators/heartbeat'
48
- require 'pubnub/validators/here_now'
49
- require 'pubnub/validators/history'
50
- require 'pubnub/validators/leave'
51
- require 'pubnub/validators/presence'
52
- require 'pubnub/validators/publish'
53
- require 'pubnub/validators/revoke'
54
- require 'pubnub/validators/set_state'
55
- require 'pubnub/validators/state'
56
- require 'pubnub/validators/subscribe'
57
- require 'pubnub/validators/time'
58
- require 'pubnub/validators/where_now'
59
- require 'pubnub/validators/delete'
60
- require 'pubnub/validators/message_counts'
61
- require 'pubnub/validators/add_channels_to_push'
62
- require 'pubnub/validators/list_push_provisions'
63
- require 'pubnub/validators/remove_channels_from_push'
64
- require 'pubnub/validators/remove_device_from_push'
65
- require 'pubnub/validators/signal'
66
- require 'pubnub/validators/set_uuid_metadata'
67
- require 'pubnub/validators/set_channel_metadata'
68
- require 'pubnub/validators/remove_uuid_metadata'
69
- require 'pubnub/validators/remove_channel_metadata'
70
- require 'pubnub/validators/get_uuid_metadata'
71
- require 'pubnub/validators/get_all_uuid_metadata'
72
- require 'pubnub/validators/get_channel_metadata'
73
- require 'pubnub/validators/get_all_channels_metadata'
74
- require 'pubnub/validators/get_channel_members'
75
- require 'pubnub/validators/get_memberships'
76
- require 'pubnub/validators/set_channel_members'
77
- require 'pubnub/validators/set_memberships'
78
- require 'pubnub/validators/remove_channel_members'
79
- require 'pubnub/validators/remove_memberships'
80
- require 'pubnub/cbor'
81
-
82
- Dir[File.join(File.dirname(__dir__), 'pubnub', 'events', '*.rb')].each do |file|
3
+ require "base64"
4
+
5
+ require "pubnub/error"
6
+ require "pubnub/uuid"
7
+ require "pubnub/formatter"
8
+ require "pubnub/constants"
9
+ require "pubnub/configuration"
10
+ require "pubnub/subscribe_callback"
11
+
12
+ require "pubnub/modules/crypto/module"
13
+
14
+ require "pubnub/schemas/envelope_schema"
15
+
16
+ require "pubnub/event"
17
+ require "pubnub/single_event"
18
+ require "pubnub/subscribe_event/callbacks"
19
+ require "pubnub/subscribe_event/formatter"
20
+ require "pubnub/subscribe_event/heartbeat"
21
+ require "pubnub/subscribe_event/adding"
22
+ require "pubnub/subscribe_event/removing"
23
+ require "pubnub/subscribe_event"
24
+ require "pubnub/pam"
25
+ require "pubnub/heart"
26
+ require "pubnub/subscriber"
27
+ require "pubnub/telemetry"
28
+
29
+ require "pubnub/envelope"
30
+ require "pubnub/error_envelope"
31
+
32
+ require "pubnub/client/events"
33
+ require "pubnub/client/paged_history"
34
+ require "pubnub/client/helpers"
35
+ require "pubnub/client/getters_setters"
36
+
37
+ require "pubnub/validators/get_message_actions"
38
+ require "pubnub/validators/add_message_action"
39
+ require "pubnub/validators/remove_message_action"
40
+ require "pubnub/validators/common_validator"
41
+ require "pubnub/validators/client"
42
+ require "pubnub/validators/audit"
43
+ require "pubnub/validators/channel_registration"
44
+ require "pubnub/validators/grant"
45
+ require "pubnub/validators/grant_token"
46
+ require "pubnub/validators/revoke_token"
47
+ require "pubnub/validators/heartbeat"
48
+ require "pubnub/validators/here_now"
49
+ require "pubnub/validators/history"
50
+ require "pubnub/validators/fetch_messages"
51
+ require "pubnub/validators/leave"
52
+ require "pubnub/validators/presence"
53
+ require "pubnub/validators/publish"
54
+ require "pubnub/validators/revoke"
55
+ require "pubnub/validators/set_state"
56
+ require "pubnub/validators/state"
57
+ require "pubnub/validators/subscribe"
58
+ require "pubnub/validators/time"
59
+ require "pubnub/validators/where_now"
60
+ require "pubnub/validators/delete"
61
+ require "pubnub/validators/message_counts"
62
+ require "pubnub/validators/add_channels_to_push"
63
+ require "pubnub/validators/list_push_provisions"
64
+ require "pubnub/validators/remove_channels_from_push"
65
+ require "pubnub/validators/remove_device_from_push"
66
+ require "pubnub/validators/signal"
67
+ require "pubnub/validators/set_uuid_metadata"
68
+ require "pubnub/validators/set_channel_metadata"
69
+ require "pubnub/validators/remove_uuid_metadata"
70
+ require "pubnub/validators/remove_channel_metadata"
71
+ require "pubnub/validators/get_uuid_metadata"
72
+ require "pubnub/validators/get_all_uuid_metadata"
73
+ require "pubnub/validators/get_channel_metadata"
74
+ require "pubnub/validators/get_all_channels_metadata"
75
+ require "pubnub/validators/get_channel_members"
76
+ require "pubnub/validators/get_memberships"
77
+ require "pubnub/validators/set_channel_members"
78
+ require "pubnub/validators/set_memberships"
79
+ require "pubnub/validators/remove_channel_members"
80
+ require "pubnub/validators/remove_memberships"
81
+ require "pubnub/cbor"
82
+
83
+ Dir[File.join(File.dirname(__dir__), "pubnub", "events", "*.rb")].each do |file|
83
84
  require file
84
85
  end
85
86
 
@@ -188,7 +189,7 @@ module Pubnub
188
189
  validate! @env
189
190
  setup_crypto_module
190
191
  @telemetry = Telemetry.new
191
- Pubnub.logger.debug('Pubnub::Client') do
192
+ Pubnub.logger.debug("Pubnub::Client") do
192
193
  "Created new Pubnub::Client instance. Version: #{Pubnub::VERSION}"
193
194
  end
194
195
  end
@@ -260,8 +261,8 @@ module Pubnub
260
261
  # created and returns it if created, otherwise creates it, assigns
261
262
  # it in @env and returns newly created dispatcher.
262
263
  def request_dispatcher(origin, event_type, sync)
263
- Pubnub.logger.debug('Pubnub::Client') do
264
- "Looking for requester for #{sync ? 'sync' : 'async'} #{event_type}"
264
+ Pubnub.logger.debug("Pubnub::Client") do
265
+ "Looking for requester for #{sync ? "sync" : "async"} #{event_type}"
265
266
  end
266
267
 
267
268
  if sync
@@ -289,21 +290,21 @@ module Pubnub
289
290
  # ==============
290
291
  # Terminates request dispatcher for given origin and event type. Usable while restarting subscription.
291
292
  def kill_request_dispatcher(origin, event_type)
292
- Pubnub.logger.debug('Pubnub::Client') { 'Killing requester' }
293
+ Pubnub.logger.debug("Pubnub::Client") { "Killing requester" }
293
294
  # @env[:req_dispatchers_pool][origin][event_type].async.terminate
294
295
  @env[:req_dispatchers_pool][:async][origin][event_type].reset_all
295
296
  @env[:req_dispatchers_pool][:async][origin][event_type] = nil
296
- rescue StandardError
297
- Pubnub.logger.debug('Pubnub::Client') { 'There\'s no requester' }
297
+ rescue
298
+ Pubnub.logger.debug("Pubnub::Client") { "There's no requester" }
298
299
  end
299
300
 
300
301
  def sequence_number_for_publish!
301
302
  @env[:sequence_number_for_publish] += 1
302
- @env[:sequence_number_for_publish] % 2 ** 32
303
+ @env[:sequence_number_for_publish] % 2**32
303
304
  end
304
305
 
305
306
  def apply_state(event)
306
- Pubnub.logger.debug('Pubnub::Client') { 'Apply state' }
307
+ Pubnub.logger.debug("Pubnub::Client") { "Apply state" }
307
308
  create_state_pools(event)
308
309
 
309
310
  return unless event.state
@@ -361,11 +362,11 @@ module Pubnub
361
362
  end
362
363
 
363
364
  def setup_httpclient(event_type)
364
- hc = if ENV['HTTP_PROXY']
365
- HTTPClient.new(ENV['HTTP_PROXY'])
366
- else
367
- HTTPClient.new
368
- end
365
+ hc = if ENV["HTTP_PROXY"]
366
+ HTTPClient.new(ENV["HTTP_PROXY"])
367
+ else
368
+ HTTPClient.new
369
+ end
369
370
 
370
371
  case event_type
371
372
  when :subscribe_event
@@ -394,14 +395,14 @@ module Pubnub
394
395
  end
395
396
 
396
397
  def setup_app(options)
397
- Pubnub.logger = options[:logger] || Logger.new('pubnub.log')
398
+ Pubnub.logger = options[:logger] || Logger.new("pubnub.log")
398
399
  Concurrent.global_logger = Pubnub.logger
399
400
  @subscriber = Subscriber.new(self)
400
401
  options[:user_id] = options[:uuid] if options[:user_id].nil?
401
402
 
402
403
  if options[:cipher_key] && options[:crypto_module]
403
- puts 'It is expected that only cipherKey or cryptoModule will be configured ' \
404
- 'at once. PubNub client will use the configured cryptoModule.'
404
+ puts "It is expected that only cipherKey or cryptoModule will be configured " \
405
+ "at once. PubNub client will use the configured cryptoModule."
405
406
  end
406
407
 
407
408
  @env = options
@@ -48,6 +48,8 @@ module Pubnub
48
48
  OPERATION_PRESENCE_LEAVE = :leave
49
49
  OPERATION_TIME = :time
50
50
  OPERATION_HISTORY = :history
51
+ OPERATION_FETCH_MESSAGES = :fetch_messages
52
+ OPERATION_FETCH_MESSAGES_WITH_ACTIONS = :fetch_messages_with_actions
51
53
  OPERATION_HERE_NOW = :here_now
52
54
  OPERATION_WHERE_NOW = :where_now
53
55
  OPERATION_GLOBAL_HERE_NOW = :global_here_now
@@ -89,7 +91,8 @@ module Pubnub
89
91
 
90
92
  OPERATIONS = [
91
93
  OPERATION_SUBSCRIBE, OPERATION_HEARTBEAT, OPERATION_PRESENCE, OPERATION_TIME, OPERATION_HISTORY,
92
- OPERATION_HERE_NOW, OPERATION_GLOBAL_HERE_NOW, OPERATION_GET_STATE, OPERATION_ADD_MESSAGE_ACTION,
94
+ OPERATION_FETCH_MESSAGES, OPERATION_FETCH_MESSAGES_WITH_ACTIONS, OPERATION_HERE_NOW,
95
+ OPERATION_GLOBAL_HERE_NOW, OPERATION_GET_STATE, OPERATION_ADD_MESSAGE_ACTION,
93
96
  OPERATION_REMOVE_MESSAGE_ACTION, OPERATION_GET_MESSAGE_ACTIONS, OPERATION_LIST_ALL_CHANNEL_GROUPS,
94
97
  OPERATION_LIST_ALL_CHANNELS_IN_CHANNEL_GROUP, OPERATION_CHANNEL_GROUP_ADD, OPERATION_CHANNEL_GROUP_REMOVE,
95
98
  OPERATION_AUDIT, OPERATION_GRANT, OPERATION_GRANT_TOKEN, OPERATION_REVOKE, OPERATION_WHERE_NOW,
data/lib/pubnub/event.rb CHANGED
@@ -65,14 +65,14 @@ module Pubnub
65
65
 
66
66
  begin
67
67
  @app.record_telemetry(@telemetry_name, telemetry_time_start, ::Time.now.to_f)
68
- rescue StandardError => error
69
- Pubnub.logger.warn('Pubnub::Event') { "Couldn't record telemetry because of #{error}\n#{error.backtrace.join("\n")}" }
68
+ rescue StandardError => e
69
+ Pubnub.logger.warn('Pubnub::Event') { "Couldn't record telemetry because of #{e}\n#{e.backtrace.join("\n")}" }
70
70
  end
71
71
 
72
72
  response
73
- rescue StandardError => error
74
- Pubnub.logger.error('Pubnub::Event') { error }
75
- error
73
+ rescue StandardError => e
74
+ Pubnub.logger.error('Pubnub::Event') { e }
75
+ e
76
76
  end
77
77
 
78
78
  def uri(memo = true)
@@ -133,8 +133,8 @@ module Pubnub
133
133
 
134
134
  def secure_call(cb, arg)
135
135
  cb.call arg
136
- rescue StandardError => error
137
- Pubnub.logger.error('Pubnub::Event') { "Error while calling callback #{error.inspect}" }
136
+ rescue StandardError => e
137
+ Pubnub.logger.error('Pubnub::Event') { "Error while calling callback #{e.inspect}" }
138
138
  end
139
139
 
140
140
  def fire_callbacks(envelope)
@@ -150,7 +150,7 @@ module Pubnub
150
150
 
151
151
  token = @app.env[:token]
152
152
  empty_if_blank = {
153
- auth: token ? token : @auth_key,
153
+ auth: token || @auth_key,
154
154
  uuid: @app.user_id,
155
155
  @telemetry_name => @current_telemetry
156
156
  }
@@ -169,21 +169,26 @@ module Pubnub
169
169
  end
170
170
 
171
171
  def create_variables_from_options(options)
172
- variables = %w[channel channels message http_sync callback
173
- ssl cipher_key random_iv crypto_module secret_key auth_key
174
- publish_key subscribe_key timetoken action_timetoken message_timetoken
175
- open_timeout read_timeout idle_timeout heartbeat
176
- group action read write delete manage ttl presence start
177
- end count limit reverse presence_callback store skip_validate
178
- state channel_group channel_groups compressed meta customs include_token
179
- replicate with_presence cipher_key_selector include_meta join update get
180
- add remove push_token push_gateway environment topic authorized_uuid
181
- authorized_user_id token type value
182
- ]
172
+ variables = %w[channel channels message http_sync callback ssl cipher_key random_iv
173
+ crypto_module secret_key auth_key publish_key subscribe_key timetoken
174
+ action_timetoken message_timetoken open_timeout read_timeout idle_timeout
175
+ heartbeat group action read write delete manage ttl presence start end count
176
+ limit max reverse presence_callback store skip_validate state channel_group
177
+ channel_groups compressed meta customs custom_message_type include_token
178
+ include_custom_message_type include_message_actions include_message_type
179
+ replicate with_presence cipher_key_selector include_meta include_uuid join
180
+ update get add remove push_token push_gateway environment topic
181
+ authorized_uuid authorized_user_id token type value]
183
182
 
184
183
  options = options.each_with_object({}) { |option, obj| obj[option.first.to_sym] = option.last }
185
184
 
186
- variables.each { |variable| instance_variable_set('@' + variable, options[variable.to_sym]) unless variable.nil? }
185
+ # variables.each { |variable| instance_variable_set('@' + variable, options[variable.to_sym]) unless variable.nil? }
186
+ variables.each do |variable|
187
+ next if variable.nil?
188
+
189
+ ivar = "@#{variable}"
190
+ instance_variable_set(ivar, options[variable.to_sym]) unless instance_variable_defined?(ivar) && !instance_variable_get(ivar).nil?
191
+ end
187
192
 
188
193
  return if @event != :subscribe && @event != :presence
189
194
 
@@ -208,12 +213,14 @@ module Pubnub
208
213
  def compute_cipher_key(data)
209
214
  ck = @compute_cipher_key || @cipher_key || @app.env[:cipher_key_selector] || @app.env[:cipher_key].to_s
210
215
  return ck unless ck.respond_to?(:call)
216
+
211
217
  ck.call(data)
212
218
  end
213
219
 
214
220
  def compute_random_iv(data)
215
221
  ck = @compute_random_iv || @random_iv || @app.env[:random_iv_selector] || @app.env[:random_iv].to_s
216
222
  return ck unless ck.respond_to?(:call)
223
+
217
224
  ck.call(data)
218
225
  end
219
226
 
@@ -221,9 +228,7 @@ module Pubnub
221
228
  #
222
229
  # @return [Pubnub::Crypto::CryptoProvider, nil] Crypto module for data encryption and
223
230
  # decryption.
224
- def crypto_module
225
- @crypto_module
226
- end
231
+ attr_reader :crypto_module
227
232
 
228
233
  def error_message(parsed_response)
229
234
  parsed_response['message']