Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
cp sdk-specifications/features/subscribe/event-engine/happy-path_Legacy.feature tests/acceptance/subscribe/happy-path_Legacy.feature
cp sdk-specifications/features/presence/event-engine/presence-engine_Legacy.feature tests/acceptance/subscribe/presence-engine_Legacy.feature

sudo pip3 install -r requirements-dev.txt
pip3 install --user --ignore-installed -r requirements-dev.txt
behave --junit tests/acceptance/pam
behave --junit tests/acceptance/encryption/cryptor-module.feature -t=~na=python -k
behave --junit tests/acceptance/subscribe
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-validations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
python-version: "3.11"
- name: Install Python dependencies and run acceptance tests
run: |
sudo pip3 install -r requirements-dev.txt
pip3 install --user --ignore-installed -r requirements-dev.txt
flake8 --exclude=scripts/,src/,.cache,.git,.idea,.tox,._trial_temp/,venv/ --ignore F811,E402
- name: Cancel workflow runs for commit on error
if: failure()
Expand Down
5 changes: 3 additions & 2 deletions pubnub/models/consumer/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ class PNFileMessageResult(PNMessageResult):
def __init__(
self, message, subscription,
channel, timetoken, publisher,
file_url, file_id, file_name
file_url, file_id, file_name, user_metadata=None, custom_message_type=None
):
super(PNFileMessageResult, self).__init__(message, subscription, channel, timetoken, publisher=publisher)
super(PNFileMessageResult, self).__init__(message, subscription, channel, timetoken, user_metadata, publisher,
custom_message_type=custom_message_type)
self.file_url = file_url
self.file_id = file_id
self.file_name = file_name
Expand Down
3 changes: 3 additions & 0 deletions pubnub/models/server/subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self):
self.subscribe_key = None
self.origination_timetoken = None
self.publish_metadata = None
self.user_metadata = None
self.only_channel_subscription = False
self.type = 0
self.custom_message_type = None
Expand All @@ -48,6 +49,8 @@ def from_json(cls, json_input):
if 'o' in json_input:
message.origination_timetoken = json_input['o']
message.publish_metadata = PublishMetadata.from_json(json_input['p'])
if 'u' in json_input:
message.user_metadata = json_input['u']
if 'e' in json_input:
message.type = json_input['e']
if 'cmt' in json_input:
Expand Down
9 changes: 8 additions & 1 deletion pubnub/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ def _process_incoming_payload(self, message: SubscribeMessage):
subscription=subscription_match,
timetoken=publish_meta_data.publish_timetoken,
publisher=message.issuing_client_id,
custom_message_type=message.custom_message_type,
user_metadata=message.user_metadata,
file_url=download_url,
file_id=extracted_message["file"]["id"],
file_name=extracted_message["file"]["name"]
Expand All @@ -182,7 +184,10 @@ def _process_incoming_payload(self, message: SubscribeMessage):
channel=channel,
subscription=subscription_match,
timetoken=publish_meta_data.publish_timetoken,
publisher=publisher
publisher=publisher,
custom_message_type=message.custom_message_type,
user_metadata=message.user_metadata,
error=error
)
self.announce(pn_signal_result)
return pn_signal_result
Expand All @@ -202,6 +207,8 @@ def _process_incoming_payload(self, message: SubscribeMessage):
subscription=subscription_match,
timetoken=publish_meta_data.publish_timetoken,
publisher=publisher,
custom_message_type=message.custom_message_type,
user_metadata=message.user_metadata,
error=error
)
self.announce(pn_message_result)
Expand Down
11 changes: 10 additions & 1 deletion tests/integrational/native_threads/test_subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ def test_subscribe_pub_unencrypted_unsubscribe(self):

subscribe_listener = SubscribeListener()
publish_operation = NonSubscribeListener()
metadata = {'test': 'publish'}
custom_message_type = "test"
message = "hey"

try:
Expand All @@ -298,7 +300,12 @@ def test_subscribe_pub_unencrypted_unsubscribe(self):
pubnub.subscribe().channels(ch).execute()
subscribe_listener.wait_for_connect()

pubnub_plain.publish().channel(ch).message(message).pn_async(publish_operation.callback)
pubnub_plain.publish() \
.channel(ch) \
.message(message) \
.custom_message_type(custom_message_type) \
.meta(metadata) \
.pn_async(publish_operation.callback)

if publish_operation.pn_await() is False:
self.fail("Publish operation timeout")
Expand All @@ -313,6 +320,8 @@ def test_subscribe_pub_unencrypted_unsubscribe(self):
assert result.subscription is None
assert result.timetoken > 0
assert result.message == message
assert result.custom_message_type == custom_message_type
assert result.user_metadata == metadata
assert result.error is not None
assert isinstance(result.error, binascii.Error)

Expand Down
Loading