pubnub 5.3.4 → 5.4.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 +7 -6
- data/.github/workflows/release.yml +9 -8
- data/.github/workflows/run-tests.yml +18 -13
- data/.github/workflows/run-validations.yml +11 -9
- data/.pubnub.yml +24 -4
- data/CHANGELOG.md +96 -79
- data/Gemfile +1 -0
- data/Gemfile.lock +90 -70
- 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/publish.rb +1 -0
- 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/version.rb +1 -1
- data/pubnub.gemspec +2 -2
- metadata +8 -6
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pubnub (5.
|
4
|
+
pubnub (5.4.0)
|
5
5
|
addressable (>= 2.0.0)
|
6
|
-
concurrent-ruby (~> 1.
|
7
|
-
concurrent-ruby-edge (~> 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.
|
17
|
-
public_suffix (>= 2.0.2, <
|
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
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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.
|
28
|
-
concurrent-ruby-edge (0.
|
29
|
-
concurrent-ruby (~> 1.
|
30
|
-
crack (0.
|
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.
|
33
|
-
builder (~> 3.2
|
34
|
-
cucumber-ci-environment (
|
35
|
-
cucumber-core (
|
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, <
|
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
|
42
|
-
multi_test (~> 1.1
|
43
|
-
sys-uname (~> 1.2
|
44
|
-
cucumber-ci-environment (
|
45
|
-
cucumber-core (
|
46
|
-
cucumber-gherkin (>=
|
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 (
|
49
|
-
cucumber-cucumber-expressions (17.0
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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 (
|
58
|
+
cucumber-tag-expressions (6.1.0)
|
56
59
|
debug_inspector (1.2.0)
|
57
|
-
diff-lcs (1.5.
|
58
|
-
docile (1.4.
|
59
|
-
dry-configurable (1.
|
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.
|
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.
|
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.
|
93
|
-
hashdiff (1.1.
|
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.
|
99
|
+
json (2.7.2)
|
97
100
|
language_server-protocol (3.17.0.3)
|
98
|
-
|
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.
|
102
|
-
parser (3.3.0
|
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 (
|
115
|
-
racc (1.
|
118
|
+
public_suffix (6.0.1)
|
119
|
+
racc (1.8.1)
|
116
120
|
rainbow (3.1.1)
|
117
|
-
regexp_parser (2.9.
|
118
|
-
rexml (3.
|
119
|
-
rr (3.1.
|
120
|
-
rspec (3.
|
121
|
-
rspec-core (~> 3.
|
122
|
-
rspec-expectations (~> 3.
|
123
|
-
rspec-mocks (~> 3.
|
124
|
-
rspec-core (3.
|
125
|
-
rspec-support (~> 3.
|
126
|
-
rspec-expectations (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.
|
129
|
-
rspec-mocks (3.
|
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.
|
135
|
+
rspec-support (~> 3.13.0)
|
132
136
|
rspec-retry (0.6.2)
|
133
137
|
rspec-core (> 3.3)
|
134
|
-
rspec-support (3.
|
135
|
-
rubocop (1.
|
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 (>=
|
142
|
-
|
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.
|
147
|
-
parser (>= 3.
|
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.
|
159
|
+
simplecov-html (0.13.1)
|
154
160
|
simplecov_json_formatter (0.1.4)
|
155
|
-
|
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.
|
159
|
-
vcr (6.
|
160
|
-
|
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.
|
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.
|
1
|
+
5.4.0
|
data/lib/pubnub/client/events.rb
CHANGED
@@ -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
|
8
|
-
revoke time heartbeat where_now
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
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 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']
|