Skip to content

Commit 778e05c

Browse files
parfeonSebastian Molenda
andauthored
Fix issue with missing custom message type (#203)
fix(subscribe): fix issue with missing custom message type Fix issue because of which custom message type wasn't set to the parsed subscription response objects. --------- Co-authored-by: Sebastian Molenda <[email protected]>
1 parent 7494aaa commit 778e05c

File tree

14 files changed

+217
-155
lines changed

14 files changed

+217
-155
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
cp sdk-specifications/features/subscribe/event-engine/happy-path_Legacy.feature tests/acceptance/subscribe/happy-path_Legacy.feature
8686
cp sdk-specifications/features/presence/event-engine/presence-engine_Legacy.feature tests/acceptance/subscribe/presence-engine_Legacy.feature
8787
88-
sudo pip3 install -r requirements-dev.txt
88+
pip3 install --user --ignore-installed -r requirements-dev.txt
8989
behave --junit tests/acceptance/pam
9090
behave --junit tests/acceptance/encryption/cryptor-module.feature -t=~na=python -k
9191
behave --junit tests/acceptance/subscribe

.github/workflows/run-validations.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
python-version: "3.11"
1717
- name: Install Python dependencies and run acceptance tests
1818
run: |
19-
sudo pip3 install -r requirements-dev.txt
19+
pip3 install --user --ignore-installed -r requirements-dev.txt
2020
flake8 --exclude=scripts/,src/,.cache,.git,.idea,.tox,._trial_temp/,venv/ --ignore F811,E402
2121
- name: Cancel workflow runs for commit on error
2222
if: failure()

.pubnub.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: python
2-
version: 10.0.0
2+
version: 10.0.1
33
schema: 1
44
scm: github.com/pubnub/python
55
sdks:
@@ -18,7 +18,7 @@ sdks:
1818
distributions:
1919
- distribution-type: library
2020
distribution-repository: package
21-
package-name: pubnub-10.0.0
21+
package-name: pubnub-10.0.1
2222
location: https://pypi.org/project/pubnub/
2323
supported-platforms:
2424
supported-operating-systems:
@@ -91,8 +91,8 @@ sdks:
9191
-
9292
distribution-type: library
9393
distribution-repository: git release
94-
package-name: pubnub-10.0.0
95-
location: https://github.com/pubnub/python/releases/download/10.0.0/pubnub-10.0.0.tar.gz
94+
package-name: pubnub-10.0.1
95+
location: https://github.com/pubnub/python/releases/download/10.0.1/pubnub-10.0.1.tar.gz
9696
supported-platforms:
9797
supported-operating-systems:
9898
Linux:
@@ -163,6 +163,11 @@ sdks:
163163
license-url: https://github.com/encode/httpx/blob/master/LICENSE.md
164164
is-required: Required
165165
changelog:
166+
- date: 2025-01-28
167+
version: 10.0.1
168+
changes:
169+
- type: bug
170+
text: "Fix issue because of which custom message type wasn't set to the parsed subscription response objects."
166171
- date: 2025-01-13
167172
version: 10.0.0
168173
changes:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 10.0.1
2+
January 28 2025
3+
4+
#### Fixed
5+
- Fix issue because of which custom message type wasn't set to the parsed subscription response objects.
6+
17
## 10.0.0
28
January 13 2025
39

pubnub/models/consumer/pubsub.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ class PNFileMessageResult(PNMessageResult):
4242
def __init__(
4343
self, message, subscription,
4444
channel, timetoken, publisher,
45-
file_url, file_id, file_name
45+
file_url, file_id, file_name, user_metadata=None, custom_message_type=None
4646
):
47-
super(PNFileMessageResult, self).__init__(message, subscription, channel, timetoken, publisher=publisher)
47+
super(PNFileMessageResult, self).__init__(message, subscription, channel, timetoken, user_metadata, publisher,
48+
custom_message_type=custom_message_type)
4849
self.file_url = file_url
4950
self.file_id = file_id
5051
self.file_name = file_name

pubnub/models/server/subscribe.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def __init__(self):
2828
self.subscribe_key = None
2929
self.origination_timetoken = None
3030
self.publish_metadata = None
31+
self.user_metadata = None
3132
self.only_channel_subscription = False
3233
self.type = 0
3334
self.custom_message_type = None
@@ -48,6 +49,8 @@ def from_json(cls, json_input):
4849
if 'o' in json_input:
4950
message.origination_timetoken = json_input['o']
5051
message.publish_metadata = PublishMetadata.from_json(json_input['p'])
52+
if 'u' in json_input:
53+
message.user_metadata = json_input['u']
5154
if 'e' in json_input:
5255
message.type = json_input['e']
5356
if 'cmt' in json_input:

pubnub/pubnub.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,9 @@ def presence(self, pubnub, presence):
450450
def wait_for_connect(self):
451451
if not self.connected_event.is_set():
452452
self.connected_event.wait()
453-
else:
454-
raise Exception("the instance is already connected")
453+
# failing because you don't have to wait is illogical
454+
# else:
455+
# raise Exception("the instance is already connected")
455456

456457
def channel(self, pubnub, channel):
457458
self.channel_queue.put(channel)
@@ -465,8 +466,9 @@ def membership(self, pubnub, membership):
465466
def wait_for_disconnect(self):
466467
if not self.disconnected_event.is_set():
467468
self.disconnected_event.wait()
468-
else:
469-
raise Exception("the instance is already disconnected")
469+
# failing because you don't have to wait is illogical
470+
# else:
471+
# raise Exception("the instance is already disconnected")
470472

471473
def wait_for_message_on(self, *channel_names):
472474
channel_names = list(channel_names)

pubnub/pubnub_asyncio.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,14 +593,16 @@ async def _wait_for(self, coro):
593593
async def wait_for_connect(self):
594594
if not self.connected_event.is_set():
595595
await self._wait_for(self.connected_event.wait())
596-
else:
597-
raise Exception("instance is already connected")
596+
# failing because you don't have to wait is illogical
597+
# else:
598+
# raise Exception("instance is already connected")
598599

599600
async def wait_for_disconnect(self):
600601
if not self.disconnected_event.is_set():
601602
await self._wait_for(self.disconnected_event.wait())
602-
else:
603-
raise Exception("instance is already disconnected")
603+
# failing because you don't have to wait is illogical
604+
# else:
605+
# raise Exception("instance is already disconnected")
604606

605607
async def wait_for_message_on(self, *channel_names):
606608
channel_names = list(channel_names)

pubnub/pubnub_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494

9595
class PubNubCore:
9696
"""A base class for PubNub Python API implementations"""
97-
SDK_VERSION = "10.0.0"
97+
SDK_VERSION = "10.0.1"
9898
SDK_NAME = "PubNub-Python"
9999

100100
TIMESTAMP_DIVIDER = 1000

pubnub/workers.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ def _process_incoming_payload(self, message: SubscribeMessage):
162162
subscription=subscription_match,
163163
timetoken=publish_meta_data.publish_timetoken,
164164
publisher=message.issuing_client_id,
165+
custom_message_type=message.custom_message_type,
166+
user_metadata=message.user_metadata,
165167
file_url=download_url,
166168
file_id=extracted_message["file"]["id"],
167169
file_name=extracted_message["file"]["name"]
@@ -182,7 +184,10 @@ def _process_incoming_payload(self, message: SubscribeMessage):
182184
channel=channel,
183185
subscription=subscription_match,
184186
timetoken=publish_meta_data.publish_timetoken,
185-
publisher=publisher
187+
publisher=publisher,
188+
custom_message_type=message.custom_message_type,
189+
user_metadata=message.user_metadata,
190+
error=error
186191
)
187192
self.announce(pn_signal_result)
188193
return pn_signal_result
@@ -202,6 +207,8 @@ def _process_incoming_payload(self, message: SubscribeMessage):
202207
subscription=subscription_match,
203208
timetoken=publish_meta_data.publish_timetoken,
204209
publisher=publisher,
210+
custom_message_type=message.custom_message_type,
211+
user_metadata=message.user_metadata,
205212
error=error
206213
)
207214
self.announce(pn_message_result)

0 commit comments

Comments
 (0)