pubnub 5.3.5 → 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 +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 +19 -4
- data/CHANGELOG.md +96 -85
- 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/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
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29d9b1bf2b58050bd99d049ea2416ff1cfe3cd92ee813e335a54b3ca2e9ee7ac
|
4
|
+
data.tar.gz: 274b127f964ad0059b3edbf152397e761c4437206b08f98a8b61b95081e96a16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 043f1102de6fa623327a91ba08a4d69a794b5e192970ee8607651f17c20cd0526d6e3dec0aa6cf299c3c6742c3af576e3e89e2664ca0461e8c60cb8d0e79f0cb
|
7
|
+
data.tar.gz: d8ad79fedee8ff7dc4bdeac2a044dafa91f8d5c6e67d35827e0e8657b1082cb4996c271feb4e4663497c8b408ade109674034956c522c7ac6663d8837f58ab29
|
@@ -10,7 +10,7 @@ jobs:
|
|
10
10
|
name: Check release required
|
11
11
|
if: ${{ github.event.pull_request.merged && endsWith(github.repository, '-private') != true }}
|
12
12
|
runs-on:
|
13
|
-
group: Default
|
13
|
+
group: organization/Default
|
14
14
|
outputs:
|
15
15
|
release: ${{ steps.check.outputs.ready }}
|
16
16
|
steps:
|
@@ -31,7 +31,7 @@ jobs:
|
|
31
31
|
needs: check-release
|
32
32
|
if: ${{ needs.check-release.outputs.release == 'true' }}
|
33
33
|
runs-on:
|
34
|
-
group: Default
|
34
|
+
group: organization/Default
|
35
35
|
steps:
|
36
36
|
- name: Checkout repository
|
37
37
|
uses: actions/checkout@v4
|
@@ -20,13 +20,13 @@ jobs:
|
|
20
20
|
tests:
|
21
21
|
name: Integration and Unit tests
|
22
22
|
runs-on:
|
23
|
-
group: Default
|
23
|
+
group: organization/Default
|
24
24
|
env:
|
25
25
|
NO_COVERAGE: true
|
26
26
|
strategy:
|
27
27
|
fail-fast: true
|
28
28
|
matrix:
|
29
|
-
ruby: [3.0.6, 3.1.4, 3.2.3]
|
29
|
+
ruby: [ 3.0.6, 3.1.4, 3.2.3 ]
|
30
30
|
steps:
|
31
31
|
- name: Checkout repository
|
32
32
|
uses: actions/checkout@v4
|
@@ -52,7 +52,7 @@ jobs:
|
|
52
52
|
acceptance-tests:
|
53
53
|
name: Acceptance tests
|
54
54
|
runs-on:
|
55
|
-
group: Default
|
55
|
+
group: organization/Default
|
56
56
|
steps:
|
57
57
|
- name: Checkout project
|
58
58
|
uses: actions/checkout@v4
|
@@ -67,11 +67,15 @@ jobs:
|
|
67
67
|
uses: ./.github/.release/actions/actions/mock-server
|
68
68
|
with:
|
69
69
|
token: ${{ secrets.GH_TOKEN }}
|
70
|
-
- name: Setup Ruby 3.
|
70
|
+
- name: Setup Ruby 3.2.2
|
71
71
|
uses: ruby/setup-ruby@v1
|
72
72
|
with:
|
73
|
-
ruby-version: 3.
|
73
|
+
ruby-version: 3.2.2
|
74
74
|
bundler-cache: true
|
75
|
+
- name: Verify Ruby Version
|
76
|
+
run: ruby -v
|
77
|
+
- name: Check Ruby Version for Bundler
|
78
|
+
run: bundle exec ruby -v
|
75
79
|
- name: Run acceptance tests (optional)
|
76
80
|
run: bundle exec cucumber sdk-specifications/features/ -p mock -p run_beta -p report_beta -f pretty
|
77
81
|
continue-on-error: true
|
@@ -84,7 +88,7 @@ jobs:
|
|
84
88
|
jrm ./main.xml "./main/**/*.xml" &&
|
85
89
|
jrm ./beta.xml "./beta/**/*.xml"
|
86
90
|
- name: Expose acceptance tests reports
|
87
|
-
uses: actions/upload-artifact@
|
91
|
+
uses: actions/upload-artifact@v4
|
88
92
|
if: always()
|
89
93
|
with:
|
90
94
|
name: acceptance-test-reports
|
@@ -97,9 +101,9 @@ jobs:
|
|
97
101
|
uses: ./.github/.release/actions/actions/utils/fast-jobs-failure
|
98
102
|
all-tests:
|
99
103
|
name: Tests
|
100
|
-
needs: [tests, acceptance-tests]
|
104
|
+
needs: [ tests, acceptance-tests ]
|
101
105
|
runs-on:
|
102
|
-
group: Default
|
106
|
+
group: organization/Default
|
103
107
|
steps:
|
104
108
|
- name: Tests summary
|
105
109
|
run: echo -e "\033[38;2;95;215;0m\033[1mAll tests successfully passed"
|
@@ -6,7 +6,7 @@ jobs:
|
|
6
6
|
pubnub-yml:
|
7
7
|
name: "Validate .pubnub.yml"
|
8
8
|
runs-on:
|
9
|
-
group: Default
|
9
|
+
group: organization/Default
|
10
10
|
steps:
|
11
11
|
- name: Checkout project
|
12
12
|
uses: actions/checkout@v4
|
@@ -28,7 +28,7 @@ jobs:
|
|
28
28
|
name: Validations
|
29
29
|
needs: [pubnub-yml]
|
30
30
|
runs-on:
|
31
|
-
group: Default
|
31
|
+
group: organization/Default
|
32
32
|
steps:
|
33
33
|
- name: Validations summary
|
34
34
|
run: echo -e "\033[38;2;95;215;0m\033[1mAll validations passed"
|
data/.pubnub.yml
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
---
|
2
|
-
version: "5.
|
2
|
+
version: "5.4.0"
|
3
3
|
changelog:
|
4
|
+
- date: 2025-01-07
|
5
|
+
version: v5.4.0
|
6
|
+
changes:
|
7
|
+
- type: feature
|
8
|
+
text: "Add batch history support."
|
9
|
+
- type: feature
|
10
|
+
text: "Add fetch messages with message reactions."
|
11
|
+
- type: feature
|
12
|
+
text: "Add fetch messages (batch history) endpoint support to fetch history for multiple channels."
|
13
|
+
- type: feature
|
14
|
+
text: "Add fetch messages with reactions support."
|
15
|
+
- type: feature
|
16
|
+
text: "Add `include_custom_message_type` support for fetch messages endpoint."
|
17
|
+
- type: feature
|
18
|
+
text: "Add `custom_message_type` support for `publish` / `signal` and `subscribe` endpoints."
|
4
19
|
- date: 2024-10-09
|
5
20
|
version: v5.3.5
|
6
21
|
changes:
|
@@ -581,7 +596,7 @@ sdks:
|
|
581
596
|
- x86-64
|
582
597
|
- distribution-type: package
|
583
598
|
distribution-repository: RubyGems
|
584
|
-
package-name: pubnub-5.
|
599
|
+
package-name: pubnub-5.4.0.gem
|
585
600
|
location: https://rubygems.org/gems/pubnub
|
586
601
|
requires:
|
587
602
|
- name: addressable
|
@@ -686,8 +701,8 @@ sdks:
|
|
686
701
|
- x86-64
|
687
702
|
- distribution-type: library
|
688
703
|
distribution-repository: GitHub release
|
689
|
-
package-name: pubnub-5.
|
690
|
-
location: https://github.com/pubnub/ruby/releases/download/v5.
|
704
|
+
package-name: pubnub-5.4.0.gem
|
705
|
+
location: https://github.com/pubnub/ruby/releases/download/v5.4.0/pubnub-5.4.0.gem
|
691
706
|
requires:
|
692
707
|
- name: addressable
|
693
708
|
min-version: 2.0.0
|
data/CHANGELOG.md
CHANGED
@@ -1,88 +1,99 @@
|
|
1
|
-
## v5.
|
2
|
-
|
3
|
-
|
4
|
-
####
|
5
|
-
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
1
|
+
## v5.4.0
|
2
|
+
January 07 2025
|
3
|
+
|
4
|
+
#### Added
|
5
|
+
- Add batch history support.
|
6
|
+
- Add fetch messages with message reactions.
|
7
|
+
- Add fetch messages (batch history) endpoint support to fetch history for multiple channels.
|
8
|
+
- Add fetch messages with reactions support.
|
9
|
+
- Add `include_custom_message_type` support for fetch messages endpoint.
|
10
|
+
- Add `custom_message_type` support for `publish` / `signal` and `subscribe` endpoints.
|
11
|
+
|
12
|
+
## v5.3.5
|
13
|
+
October 09 2024
|
14
|
+
|
15
|
+
#### Modified
|
16
|
+
- Updated direct and transient dependency versions. Fixed the following issues reported by [@pboling](https://github.com/pboling): [#158](https://github.com/pubnub/ruby/issues/158).
|
17
|
+
|
18
|
+
## v5.3.4
|
19
|
+
April 29 2024
|
20
|
+
|
21
|
+
#### Fixed
|
22
|
+
- Fix issue because of which client didn't encode App Context get all event `filter` query value.
|
23
|
+
|
24
|
+
## v5.3.3
|
25
|
+
January 29 2024
|
26
|
+
|
27
|
+
#### Modified
|
28
|
+
- Bump required version to the minimum officially supported Ruby version.
|
29
|
+
|
30
|
+
## v5.3.2
|
31
|
+
November 23 2023
|
32
|
+
|
33
|
+
#### Modified
|
34
|
+
- Return source event data when a client configured with crypto is unable to decrypt it (can be not encrypted data or encrypted with different options).
|
35
|
+
|
36
|
+
## v5.3.1
|
37
|
+
November 03 2023
|
38
|
+
|
39
|
+
#### Modified
|
40
|
+
- Update license information.
|
41
|
+
|
42
|
+
## v5.3.0
|
43
|
+
October 16 2023
|
44
|
+
|
45
|
+
#### Added
|
46
|
+
- Add crypto module that allows to configure SDK to encrypt and decrypt messages.
|
47
|
+
|
48
|
+
#### Fixed
|
49
|
+
- Improved security of crypto implementation by adding enhanced AES-CBC cryptor.
|
50
|
+
|
51
|
+
## v5.2.2
|
52
|
+
March 14 2023
|
53
|
+
|
54
|
+
#### Fixed
|
55
|
+
- Fix issue which raised an exception when PubNub client has been configured with a secret key.
|
56
|
+
|
57
|
+
## v5.2.1
|
58
|
+
December 13 2022
|
59
|
+
|
60
|
+
#### Fixed
|
61
|
+
- Fix format which is used to return server data from `get_message_actions` method call.
|
62
|
+
|
63
|
+
## v5.2.0
|
64
|
+
December 12 2022
|
65
|
+
|
66
|
+
#### Added
|
67
|
+
- Add api which allow to work with message actions endpoints.
|
68
|
+
|
69
|
+
#### Modified
|
70
|
+
- Migrate test suite run from Travis to GitHub Actions.
|
71
|
+
|
72
|
+
## v5.1.2
|
73
|
+
November 23 2022
|
74
|
+
|
75
|
+
#### Fixed
|
76
|
+
- Fix issue because of which channel hasn't been encoded properly with endpoint call.
|
77
|
+
|
78
|
+
## v5.1.1
|
79
|
+
October 26 2022
|
80
|
+
|
81
|
+
#### Fixed
|
82
|
+
- Fix issue because of which `callback` and `http_sync` provided during client configuration not used when missing in method call.
|
83
|
+
|
84
|
+
## v5.1.0
|
85
|
+
July 26 2022
|
86
|
+
|
87
|
+
#### Added
|
88
|
+
- Add support for spaces and users permissions in grant_token.
|
89
|
+
- Add user_id and deprecate uuid when creating new pubnub instance.
|
90
|
+
|
91
|
+
## v5.0.0
|
92
|
+
January 13 2022
|
93
|
+
|
94
|
+
#### Modified
|
95
|
+
- BREAKING CHANGES: uuid is required parameter to create PubNub instance.
|
96
|
+
|
86
97
|
## v4.8.0
|
87
98
|
December 16 2021
|
88
99
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pubnub (5.
|
4
|
+
pubnub (5.4.0)
|
5
5
|
addressable (>= 2.0.0)
|
6
6
|
concurrent-ruby (~> 1.3.4)
|
7
7
|
concurrent-ruby-edge (~> 0.7.1)
|
@@ -98,6 +98,7 @@ GEM
|
|
98
98
|
interception (0.5)
|
99
99
|
json (2.7.2)
|
100
100
|
language_server-protocol (3.17.0.3)
|
101
|
+
lint_roller (1.1.0)
|
101
102
|
method_source (1.1.0)
|
102
103
|
mini_mime (1.1.5)
|
103
104
|
multi_test (1.1.0)
|
@@ -147,6 +148,9 @@ GEM
|
|
147
148
|
unicode-display_width (>= 2.4.0, < 3.0)
|
148
149
|
rubocop-ast (1.32.3)
|
149
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)
|
150
154
|
ruby-progressbar (1.13.0)
|
151
155
|
simplecov (0.22.0)
|
152
156
|
docile (~> 1.1)
|
@@ -154,6 +158,18 @@ GEM
|
|
154
158
|
simplecov_json_formatter (~> 0.1)
|
155
159
|
simplecov-html (0.13.1)
|
156
160
|
simplecov_json_formatter (0.1.4)
|
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)
|
157
173
|
sys-uname (1.3.0)
|
158
174
|
ffi (~> 1.1)
|
159
175
|
timers (4.3.5)
|
@@ -183,6 +199,7 @@ DEPENDENCIES
|
|
183
199
|
rspec-retry
|
184
200
|
rubocop
|
185
201
|
simplecov (>= 0.21.2)
|
202
|
+
standard
|
186
203
|
vcr
|
187
204
|
webmock
|
188
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']
|
@@ -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
|
data/lib/pubnub/events/signal.rb
CHANGED
@@ -26,6 +26,10 @@ module Pubnub
|
|
26
26
|
def parameters(*_args)
|
27
27
|
params = super
|
28
28
|
|
29
|
+
empty_if_blank = { custom_message_type: @custom_message_type }
|
30
|
+
empty_if_blank.delete_if { |_k, v| v.blank? }
|
31
|
+
|
32
|
+
params = params.merge(empty_if_blank)
|
29
33
|
params = params.merge(seqn: @sequence_number,
|
30
34
|
ortt: { t: @origination_time_token })
|
31
35
|
params
|
@@ -60,6 +60,7 @@ module Pubnub
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def plain_envelope(req_res_objects, timetoken)
|
63
|
+
operation = get_operation
|
63
64
|
Pubnub::Envelope.new(
|
64
65
|
event: @event,
|
65
66
|
event_options: @given_options,
|
@@ -82,7 +83,7 @@ module Pubnub
|
|
82
83
|
},
|
83
84
|
result: {
|
84
85
|
code: req_res_objects[:response].code,
|
85
|
-
operation:
|
86
|
+
operation: operation,
|
86
87
|
client_request: req_res_objects[:request],
|
87
88
|
server_response: req_res_objects[:response],
|
88
89
|
|
@@ -92,6 +93,20 @@ module Pubnub
|
|
92
93
|
end
|
93
94
|
|
94
95
|
def encrypted_envelope(req_res_objects, message, timetoken)
|
96
|
+
operation = get_operation(message)
|
97
|
+
data = {
|
98
|
+
message: decipher_payload(message),
|
99
|
+
subscribed_channel: message[:subscription_match] || message[:channel],
|
100
|
+
actual_channel: message[:channel],
|
101
|
+
publish_time_object: message[:publish_timetoken],
|
102
|
+
message_meta_data: message[:user_meta_data],
|
103
|
+
presence_event: get_presence_event(message),
|
104
|
+
presence: get_presence_data(message)
|
105
|
+
}
|
106
|
+
if !data[:actual_channel].end_with?('-pnpres') && (message[:type].nil? || [1, 4].include?(message[:type]))
|
107
|
+
data[:custom_message_type] = message[:custom_message_type]
|
108
|
+
end
|
109
|
+
|
95
110
|
Pubnub::Envelope.new(
|
96
111
|
event: @event,
|
97
112
|
event_options: @given_options,
|
@@ -114,19 +129,11 @@ module Pubnub
|
|
114
129
|
},
|
115
130
|
result: {
|
116
131
|
code: req_res_objects[:response].code,
|
117
|
-
operation:
|
132
|
+
operation: operation,
|
118
133
|
client_request: req_res_objects[:request],
|
119
134
|
server_response: req_res_objects[:response],
|
120
135
|
|
121
|
-
data:
|
122
|
-
message: decipher_payload(message),
|
123
|
-
subscribed_channel: message[:subscription_match] || message[:channel],
|
124
|
-
actual_channel: message[:channel],
|
125
|
-
publish_time_object: message[:publish_timetoken],
|
126
|
-
message_meta_data: message[:user_meta_data],
|
127
|
-
presence_event: get_presence_event(message),
|
128
|
-
presence: get_presence_data(message)
|
129
|
-
}
|
136
|
+
data: data
|
130
137
|
}
|
131
138
|
)
|
132
139
|
end
|
@@ -142,10 +149,10 @@ module Pubnub
|
|
142
149
|
Pubnub::Schemas::Envelope::StatusSchema.new.call status
|
143
150
|
end
|
144
151
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
152
|
+
return unless (results_validation + statuses_validation).map(&:failure?).index(true)
|
153
|
+
|
154
|
+
Pubnub.logger.error('Pubnub::SubscribeEvent::Formatter') { 'Invalid formatted envelope.' }
|
155
|
+
raise Exception, 'Invalid formatted envelope.'
|
149
156
|
end
|
150
157
|
|
151
158
|
def format_envelopes(response, request)
|
@@ -216,6 +223,7 @@ module Pubnub
|
|
216
223
|
|
217
224
|
def get_presence_data(message)
|
218
225
|
return nil unless get_operation(message) == Pubnub::Constants::OPERATION_PRESENCE
|
226
|
+
|
219
227
|
{
|
220
228
|
uuid: message[:payload]['uuid'],
|
221
229
|
timestamp: message[:payload]['timestamp'],
|
@@ -226,6 +234,7 @@ module Pubnub
|
|
226
234
|
|
227
235
|
def get_presence_event(message)
|
228
236
|
return nil unless get_operation(message) == Pubnub::Constants::OPERATION_PRESENCE
|
237
|
+
|
229
238
|
message[:payload]['action']
|
230
239
|
rescue StandardError
|
231
240
|
nil
|
@@ -233,7 +242,7 @@ module Pubnub
|
|
233
242
|
|
234
243
|
def expand_messages_keys(messages)
|
235
244
|
messages.map do |m|
|
236
|
-
{
|
245
|
+
envelope = {
|
237
246
|
shard: m['a'],
|
238
247
|
channel: m['c'],
|
239
248
|
subscription_match: m['b'],
|
@@ -250,11 +259,15 @@ module Pubnub
|
|
250
259
|
origination_time_token: expand_timetoken(m['o']),
|
251
260
|
publish_timetoken: expand_timetoken(m['p'])
|
252
261
|
}
|
262
|
+
envelope[:custom_message_type] = m['cmt'] if !m['c'].end_with?('-pnpres') && (envelope[:type].nil? || [1, 4].include?(envelope[:type]))
|
263
|
+
|
264
|
+
envelope
|
253
265
|
end
|
254
266
|
end
|
255
267
|
|
256
268
|
def expand_timetoken(timetoken)
|
257
269
|
return nil unless timetoken
|
270
|
+
|
258
271
|
{
|
259
272
|
timetoken: timetoken['t'],
|
260
273
|
region_code: timetoken['r']
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pubnub
|
4
|
+
# Validator module that holds all validators modules.
|
5
|
+
module Validator
|
6
|
+
# Validator for FetchMessages event.
|
7
|
+
module FetchMessages
|
8
|
+
include CommonValidator
|
9
|
+
|
10
|
+
def validate!
|
11
|
+
return if @skip_validate
|
12
|
+
|
13
|
+
validate_subscribe_key!
|
14
|
+
validate_channel_or_channels!
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def validate_subscribe_key!
|
20
|
+
return unless @subscribe_key.nil?
|
21
|
+
|
22
|
+
raise(
|
23
|
+
ArgumentError.new(object: self, message: ':subscribe_key is required for fetch messages event'),
|
24
|
+
':subscribe_key is required for fetch messages event'
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
def validate_channel_or_channels!
|
29
|
+
error_message = nil
|
30
|
+
if @include_message_actions
|
31
|
+
error_message = ":channels can't be used with :include_custom_message_type set to 'true'" unless @channels.nil?
|
32
|
+
error_message = ":channel is required with :include_custom_message_type set to 'true'" if @channel.nil?
|
33
|
+
elsif @channels.nil? || @channels.empty?
|
34
|
+
error_message = ':channels is required for fetch message event'
|
35
|
+
end
|
36
|
+
|
37
|
+
raise(ArgumentError.new(object: self, message: error_message), error_message) unless error_message.nil?
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/pubnub/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pubnub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PubNub
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -184,6 +184,7 @@ files:
|
|
184
184
|
- lib/pubnub/events/audit.rb
|
185
185
|
- lib/pubnub/events/channel_registration.rb
|
186
186
|
- lib/pubnub/events/delete_messages.rb
|
187
|
+
- lib/pubnub/events/fetch_messages.rb
|
187
188
|
- lib/pubnub/events/get_all_channels_metadata.rb
|
188
189
|
- lib/pubnub/events/get_all_uuid_metadata.rb
|
189
190
|
- lib/pubnub/events/get_channel_members.rb
|
@@ -251,6 +252,7 @@ files:
|
|
251
252
|
- lib/pubnub/validators/client.rb
|
252
253
|
- lib/pubnub/validators/common_validator.rb
|
253
254
|
- lib/pubnub/validators/delete.rb
|
255
|
+
- lib/pubnub/validators/fetch_messages.rb
|
254
256
|
- lib/pubnub/validators/get_all_channels_metadata.rb
|
255
257
|
- lib/pubnub/validators/get_all_uuid_metadata.rb
|
256
258
|
- lib/pubnub/validators/get_channel_members.rb
|