pubnub 5.3.5 → 5.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/commands-handler.yml +1 -1
- data/.github/workflows/release.yml +2 -2
- data/.github/workflows/run-tests.yml +12 -8
- data/.github/workflows/run-validations.yml +2 -2
- data/.pubnub.yml +26 -4
- data/CHANGELOG.md +100 -82
- data/Gemfile +1 -0
- data/Gemfile.lock +18 -1
- data/VERSION +1 -1
- data/lib/pubnub/client/events.rb +10 -8
- data/lib/pubnub/client.rb +97 -96
- data/lib/pubnub/constants.rb +4 -1
- data/lib/pubnub/event.rb +28 -23
- data/lib/pubnub/events/fetch_messages.rb +128 -0
- data/lib/pubnub/events/get_all_channels_metadata.rb +13 -9
- data/lib/pubnub/events/get_all_uuid_metadata.rb +13 -9
- data/lib/pubnub/events/get_channel_members.rb +18 -15
- data/lib/pubnub/events/get_channel_metadata.rb +9 -5
- data/lib/pubnub/events/get_memberships.rb +18 -15
- data/lib/pubnub/events/get_uuid_metadata.rb +9 -5
- data/lib/pubnub/events/publish.rb +1 -0
- data/lib/pubnub/events/set_channel_members.rb +18 -13
- data/lib/pubnub/events/set_channel_metadata.rb +8 -4
- data/lib/pubnub/events/set_memberships.rb +18 -13
- data/lib/pubnub/events/set_uuid_metadata.rb +8 -4
- data/lib/pubnub/events/signal.rb +4 -0
- data/lib/pubnub/subscribe_event/formatter.rb +29 -16
- data/lib/pubnub/validators/fetch_messages.rb +41 -0
- data/lib/pubnub/validators/set_channel_metadata.rb +17 -13
- data/lib/pubnub/validators/set_uuid_metadata.rb +17 -13
- data/lib/pubnub/version.rb +1 -1
- metadata +8 -6
data/lib/pubnub/client.rb
CHANGED
@@ -1,85 +1,86 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
|
12
|
-
require
|
13
|
-
|
14
|
-
require
|
15
|
-
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
28
|
-
|
29
|
-
require
|
30
|
-
require
|
31
|
-
|
32
|
-
require
|
33
|
-
require
|
34
|
-
require
|
35
|
-
require
|
36
|
-
|
37
|
-
require
|
38
|
-
require
|
39
|
-
require
|
40
|
-
require
|
41
|
-
require
|
42
|
-
require
|
43
|
-
require
|
44
|
-
require
|
45
|
-
require
|
46
|
-
require
|
47
|
-
require
|
48
|
-
require
|
49
|
-
require
|
50
|
-
require
|
51
|
-
require
|
52
|
-
require
|
53
|
-
require
|
54
|
-
require
|
55
|
-
require
|
56
|
-
require
|
57
|
-
require
|
58
|
-
require
|
59
|
-
require
|
60
|
-
require
|
61
|
-
require
|
62
|
-
require
|
63
|
-
require
|
64
|
-
require
|
65
|
-
require
|
66
|
-
require
|
67
|
-
require
|
68
|
-
require
|
69
|
-
require
|
70
|
-
require
|
71
|
-
require
|
72
|
-
require
|
73
|
-
require
|
74
|
-
require
|
75
|
-
require
|
76
|
-
require
|
77
|
-
require
|
78
|
-
require
|
79
|
-
require
|
80
|
-
require
|
81
|
-
|
82
|
-
|
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(
|
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(
|
264
|
-
"Looking for requester for #{sync ?
|
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(
|
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
|
297
|
-
Pubnub.logger.debug(
|
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
|
303
|
+
@env[:sequence_number_for_publish] % 2**32
|
303
304
|
end
|
304
305
|
|
305
306
|
def apply_state(event)
|
306
|
-
Pubnub.logger.debug(
|
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[
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
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(
|
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
|
404
|
-
|
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
|
data/lib/pubnub/constants.rb
CHANGED
@@ -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
|
-
|
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 =>
|
69
|
-
Pubnub.logger.warn('Pubnub::Event') { "Couldn't record telemetry because of #{
|
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 =>
|
74
|
-
Pubnub.logger.error('Pubnub::Event') {
|
75
|
-
|
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 =>
|
137
|
-
Pubnub.logger.error('Pubnub::Event') { "Error while calling callback #{
|
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
|
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
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
replicate with_presence cipher_key_selector include_meta join
|
180
|
-
add remove push_token push_gateway environment topic
|
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 status 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
|
-
|
225
|
-
@crypto_module
|
226
|
-
end
|
231
|
+
attr_reader :crypto_module
|
227
232
|
|
228
233
|
def error_message(parsed_response)
|
229
234
|
parsed_response['message']
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pubnub
|
4
|
+
# Holds functionality to fetch:
|
5
|
+
# - batch messages (for multiple channels)
|
6
|
+
# - messages with message actions.
|
7
|
+
class FetchMessages < SingleEvent
|
8
|
+
include Concurrent::Async
|
9
|
+
include Pubnub::Validator::FetchMessages
|
10
|
+
|
11
|
+
def initialize(options, app)
|
12
|
+
@telemetry_name = :l_hist
|
13
|
+
@include_custom_message_type = options.fetch(:include_custom_message_type, false)
|
14
|
+
@include_message_actions = options.fetch(:include_message_actions, false)
|
15
|
+
@include_message_type = options.fetch(:include_message_type, true)
|
16
|
+
@include_uuid = options.fetch(:include_uuid, true)
|
17
|
+
@include_meta = options.fetch(:include_meta, false)
|
18
|
+
@start = options[:start] if options.key?(:start)
|
19
|
+
@end = options[:end] if options.key?(:end)
|
20
|
+
|
21
|
+
channel = options[:channel] if options.key?(:channel) && !options[:channel].empty?
|
22
|
+
@channels = options[:channels] if options.key?(:channels) && !options[:channels].empty?
|
23
|
+
if @include_message_actions
|
24
|
+
@channel = channel
|
25
|
+
elsif @channels.nil? && !channel.nil?
|
26
|
+
@channels = [channel]
|
27
|
+
@channel = nil
|
28
|
+
options.delete :channel
|
29
|
+
end
|
30
|
+
|
31
|
+
maximum = @include_message_actions || @channels&.size == 1 ? 100 : 25
|
32
|
+
@max = [options[:max], maximum].min unless options[:max].nil?
|
33
|
+
|
34
|
+
@event = current_operation
|
35
|
+
|
36
|
+
# Override crypto module if custom cipher key has been used.
|
37
|
+
random_iv = options.key?(:random_iv) ? options[:random_iv] : true
|
38
|
+
options[:crypto_module] = Crypto::CryptoModule.new_legacy(options[:cipher_key], random_iv) if options[:cipher_key]
|
39
|
+
|
40
|
+
super
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def current_operation
|
46
|
+
@include_message_actions ? Pubnub::Constants::OPERATION_FETCH_MESSAGES_WITH_ACTIONS : Pubnub::Constants::OPERATION_FETCH_MESSAGES
|
47
|
+
end
|
48
|
+
|
49
|
+
def parameters(signature: false)
|
50
|
+
parameters = super(signature)
|
51
|
+
parameters[:include_meta] = 'true' if @include_meta
|
52
|
+
parameters[:include_uuid] = 'true' if @include_uuid
|
53
|
+
parameters[:include_custom_message_type] = 'true' if @include_custom_message_type
|
54
|
+
parameters[:include_message_type] = 'true' if @include_message_type
|
55
|
+
parameters[:start] = @start unless @start.nil?
|
56
|
+
parameters[:end] = @end unless @end.nil?
|
57
|
+
parameters[:max] = @max unless @max.nil?
|
58
|
+
|
59
|
+
parameters
|
60
|
+
end
|
61
|
+
|
62
|
+
def path
|
63
|
+
storage_endpoint = @include_message_actions ? 'history-with-actions' : 'history'
|
64
|
+
"/v3/#{storage_endpoint}/sub-key/#{@subscribe_key}/channel/#{Pubnub::Formatter.channels_for_url((
|
65
|
+
unless @channel.nil?
|
66
|
+
[@channel]
|
67
|
+
end) || @channels)}"
|
68
|
+
end
|
69
|
+
|
70
|
+
def enable_format_channels?
|
71
|
+
false
|
72
|
+
end
|
73
|
+
|
74
|
+
def decrypt_history(crypto, message)
|
75
|
+
encrypted_message = Base64.strict_decode64(message['message'])
|
76
|
+
message['message'] = JSON.parse(crypto.decrypt(encrypted_message), quirks_mode: true)
|
77
|
+
message
|
78
|
+
rescue StandardError => e
|
79
|
+
puts "Pubnub :: DECRYPTION ERROR: #{e}"
|
80
|
+
message['decrypt_error'] = true
|
81
|
+
message
|
82
|
+
end
|
83
|
+
|
84
|
+
def valid_envelope(parsed_response, req_res_objects)
|
85
|
+
channels = parsed_response['channels'] unless parsed_response['error']
|
86
|
+
more = parsed_response['more'].transform_keys(&:to_sym) if parsed_response.key?('more')
|
87
|
+
more&.delete :url
|
88
|
+
|
89
|
+
if crypto_module && channels
|
90
|
+
crypto = crypto_module
|
91
|
+
channels.transform_values! do |channel_messages|
|
92
|
+
channel_messages.map(&method(:decrypt_history).curry[crypto])
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
Pubnub::Envelope.new(
|
97
|
+
event: @event,
|
98
|
+
event_options: @given_options,
|
99
|
+
timetoken: nil,
|
100
|
+
status: {
|
101
|
+
code: req_res_objects[:response].code,
|
102
|
+
client_request: req_res_objects[:request],
|
103
|
+
server_response: req_res_objects[:response],
|
104
|
+
|
105
|
+
category: Pubnub::Constants::STATUS_ACK,
|
106
|
+
error: false,
|
107
|
+
auto_retried: false,
|
108
|
+
|
109
|
+
data: nil,
|
110
|
+
current_timetoken: nil,
|
111
|
+
last_timetoken: nil,
|
112
|
+
subscribed_channels: nil,
|
113
|
+
subscribed_channel_groups: nil,
|
114
|
+
|
115
|
+
config: get_config
|
116
|
+
},
|
117
|
+
result: {
|
118
|
+
code: req_res_objects[:response].code,
|
119
|
+
operation: @event,
|
120
|
+
client_request: req_res_objects[:request],
|
121
|
+
server_response: req_res_objects[:response],
|
122
|
+
|
123
|
+
data: { channels: channels }.merge!(more.nil? ? {} : { more: more })
|
124
|
+
}
|
125
|
+
)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -11,18 +11,22 @@ module Pubnub
|
|
11
11
|
@event = current_operation
|
12
12
|
@telemetry_name = :l_obj
|
13
13
|
@limit = [options[:limit], 100].min unless options[:limit].nil?
|
14
|
-
@sort = options[:sort].join(
|
14
|
+
@sort = options[:sort].join(',') if options[:sort] && !options[:sort].empty?
|
15
15
|
@filter = options[:filter] if options[:filter] && !options[:filter].empty?
|
16
16
|
@start = options[:start] if options[:start] && !options[:start].empty?
|
17
17
|
@end = options[:end] if options[:start] && !options[:end].empty?
|
18
18
|
|
19
|
+
@include = []
|
19
20
|
if options[:include]
|
20
|
-
|
21
|
-
@include
|
21
|
+
include = options[:include]
|
22
|
+
@include.push('type') unless include[:type].nil? || [0, '0', false].include?(include[:type])
|
23
|
+
@include.push('status') unless include[:status].nil? || [0, '0', false].include?(include[:status])
|
24
|
+
@include.push('custom') unless include[:custom].nil? || [0, '0', false].include?(include[:custom])
|
25
|
+
@include_count = [0, '0', false].include?(include[:count]) ? '0' : '1' unless include[:count].nil?
|
22
26
|
end
|
23
27
|
|
24
28
|
# Collections by default return number of available entries.
|
25
|
-
@include_count =
|
29
|
+
@include_count = '1' if @include_count.nil?
|
26
30
|
|
27
31
|
super
|
28
32
|
end
|
@@ -41,7 +45,7 @@ module Pubnub
|
|
41
45
|
parameters[:start] = @start unless @start.nil?
|
42
46
|
parameters[:end] = @end if @end && !@start
|
43
47
|
parameters[:count] = @include_count unless @include_count.nil?
|
44
|
-
parameters[:include] = @include unless @include.
|
48
|
+
parameters[:include] = @include.sort.join(',') unless @include.empty?
|
45
49
|
|
46
50
|
parameters
|
47
51
|
end
|
@@ -56,12 +60,12 @@ module Pubnub
|
|
56
60
|
end
|
57
61
|
|
58
62
|
def valid_envelope(parsed_response, req_res_objects)
|
59
|
-
channels_metadata = parsed_response['data'].map
|
60
|
-
metadata =
|
61
|
-
uuid_metadata.each{ |k,v| metadata[k.to_sym] = v }
|
63
|
+
channels_metadata = parsed_response['data'].map do |uuid_metadata|
|
64
|
+
metadata = {}
|
65
|
+
uuid_metadata.each { |k, v| metadata[k.to_sym] = v }
|
62
66
|
metadata[:updated] = Date._parse(metadata[:updated]) unless metadata[:updated].nil?
|
63
67
|
metadata
|
64
|
-
|
68
|
+
end
|
65
69
|
|
66
70
|
Pubnub::Envelope.new(
|
67
71
|
event: @event,
|
@@ -11,18 +11,22 @@ module Pubnub
|
|
11
11
|
@event = current_operation
|
12
12
|
@telemetry_name = :l_obj
|
13
13
|
@limit = [options[:limit], 100].min unless options[:limit].nil?
|
14
|
-
@sort = options[:sort].join(
|
14
|
+
@sort = options[:sort].join(',') if options[:sort] && !options[:sort].empty?
|
15
15
|
@filter = options[:filter] if options[:filter] && !options[:filter].empty?
|
16
16
|
@start = options[:start] if options[:start] && !options[:start].empty?
|
17
17
|
@end = options[:end] if options[:start] && !options[:end].empty?
|
18
18
|
|
19
|
+
@include = []
|
19
20
|
if options[:include]
|
20
|
-
|
21
|
-
@include
|
21
|
+
include = options[:include]
|
22
|
+
@include.push('type') unless include[:type].nil? || [0, '0', false].include?(include[:type])
|
23
|
+
@include.push('status') unless include[:status].nil? || [0, '0', false].include?(include[:status])
|
24
|
+
@include.push('custom') unless include[:custom].nil? || [0, '0', false].include?(include[:custom])
|
25
|
+
@include_count = [0, '0', false].include?(include[:count]) ? '0' : '1' unless include[:count].nil?
|
22
26
|
end
|
23
27
|
|
24
28
|
# Collections by default return number of available entries.
|
25
|
-
@include_count =
|
29
|
+
@include_count = '1' if @include_count.nil?
|
26
30
|
|
27
31
|
super
|
28
32
|
end
|
@@ -41,7 +45,7 @@ module Pubnub
|
|
41
45
|
parameters[:start] = @start unless @start.nil?
|
42
46
|
parameters[:end] = @end if @end && !@start
|
43
47
|
parameters[:count] = @include_count unless @include_count.nil?
|
44
|
-
parameters[:include] = @include unless @include.
|
48
|
+
parameters[:include] = @include.sort.join(',') unless @include.empty?
|
45
49
|
|
46
50
|
parameters
|
47
51
|
end
|
@@ -56,12 +60,12 @@ module Pubnub
|
|
56
60
|
end
|
57
61
|
|
58
62
|
def valid_envelope(parsed_response, req_res_objects)
|
59
|
-
uuids_metadata = parsed_response['data'].map
|
60
|
-
metadata =
|
61
|
-
uuid_metadata.each{ |k,v| metadata[k.to_sym] = v }
|
63
|
+
uuids_metadata = parsed_response['data'].map do |uuid_metadata|
|
64
|
+
metadata = {}
|
65
|
+
uuid_metadata.each { |k, v| metadata[k.to_sym] = v }
|
62
66
|
metadata[:updated] = Date._parse(metadata[:updated]) unless metadata[:updated].nil?
|
63
67
|
metadata
|
64
|
-
|
68
|
+
end
|
65
69
|
|
66
70
|
Pubnub::Envelope.new(
|
67
71
|
event: @event,
|