Skip to content

Commit a252904

Browse files
PubNub SDK v4.5.2 release.
1 parent de315c7 commit a252904

File tree

5 files changed

+34
-21
lines changed

5 files changed

+34
-21
lines changed

.pubnub.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
name: python
2-
version: 4.5.1
2+
version: 4.5.2
33
schema: 1
44
scm: github.com/pubnub/python
55
changelog:
6+
- version: v4.5.2
7+
date: May 29, 2020
8+
changes:
9+
-
10+
text: "Fix bug with max message count parameter for Fetch Messages endpoint. Rename maximum_per_channel parameter to count for Fetch Messages, keeping the old name for compatibility."
11+
type: bug
612
- version: v4.5.1
713
date: May 4, 2020
814
changes:

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
## [v4.5.1](https://github.com/pubnub/python/releases/tag/v4.5.1)
1+
## [v4.5.2](https://github.com/pubnub/python/releases/tag/v4.5.2)
2+
3+
[Full Changelog](https://github.com/pubnub/python/compare/v4.5.1...v4.5.2)
24

3-
[Full Changelog](https://github.com/pubnub/python/compare/v4.5.0...v4.5.1)
5+
- 🐛 Fix bug with max message count parameter for Fetch Messages endpoint. Rename maximum_per_channel parameter to count for Fetch Messages, keeping the old name for compatibility.
6+
7+
## [v4.5.1](https://github.com/pubnub/python/releases/tag/v4.5.1)
48

59
- 🐛 Using SSL by default from the Python SDK to be more consistent and encourage best practices.
610

pubnub/endpoints/fetch_messages.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class FetchMessages(Endpoint):
1616
FETCH_MESSAGES_PATH = "/v3/history/sub-key/%s/channel/%s"
1717
FETCH_MESSAGES_WITH_ACTIONS_PATH = "/v3/history-with-actions/sub-key/%s/channel/%s"
1818

19-
DEFAULT_MESSAGES = 100
19+
DEFAULT_MESSAGES = 25
2020
MAX_MESSAGES = 25
2121
MAX_MESSAGES_ACTIONS = 100
2222

@@ -25,19 +25,22 @@ def __init__(self, pubnub):
2525
self._channels = []
2626
self._start = None
2727
self._end = None
28-
self._maximum_per_channel = None
28+
self._count = None
2929
self._include_meta = None
3030
self._include_message_actions = None
3131

3232
def channels(self, channels):
3333
utils.extend_list(self._channels, channels)
3434
return self
3535

36-
def maximum_per_channel(self, maximum_per_channel):
37-
assert isinstance(maximum_per_channel, six.integer_types)
38-
self._maximum_per_channel = maximum_per_channel
36+
def count(self, count):
37+
assert isinstance(count, six.integer_types)
38+
self._count = count
3939
return self
4040

41+
def maximum_per_channel(self, maximum_per_channel):
42+
return self.count(maximum_per_channel)
43+
4144
def start(self, start):
4245
assert isinstance(start, six.integer_types)
4346
self._start = start
@@ -59,7 +62,7 @@ def include_message_actions(self, include_message_actions):
5962
return self
6063

6164
def custom_params(self):
62-
params = {'max': str(self._maximum_per_channel)}
65+
params = {'max': int(self._count)}
6366

6467
if self._start is not None:
6568
params['start'] = str(self._start)
@@ -103,20 +106,20 @@ def validate_params(self):
103106
self._include_message_actions = False
104107

105108
if self._include_message_actions is False:
106-
if self._maximum_per_channel is None or self._maximum_per_channel < FetchMessages.DEFAULT_MESSAGES:
107-
self._maximum_per_channel = FetchMessages.DEFAULT_MESSAGES
108-
logger.info("maximum_per_channel param defaulting to %d", FetchMessages.DEFAULT_MESSAGES)
109-
elif self._maximum_per_channel > FetchMessages.MAX_MESSAGES:
110-
self._maximum_per_channel = FetchMessages.MAX_MESSAGES
111-
logger.info("maximum_per_channel param defaulting to %d", FetchMessages.DEFAULT_MESSAGES)
109+
if self._count is None or self._count < 1:
110+
self._count = FetchMessages.DEFAULT_MESSAGES
111+
logger.info("count param defaulting to %d", FetchMessages.DEFAULT_MESSAGES)
112+
elif self._count > FetchMessages.MAX_MESSAGES:
113+
self._count = FetchMessages.MAX_MESSAGES
114+
logger.info("count param defaulting to %d", FetchMessages.MAX_MESSAGES)
112115
else:
113116
if len(self._channels) > 1:
114117
raise PubNubException(pn_error=PNERR_HISTORY_MESSAGE_ACTIONS_MULTIPLE_CHANNELS)
115118

116-
if self._maximum_per_channel is None or self._maximum_per_channel < 1 or\
117-
self._maximum_per_channel > FetchMessages.MAX_MESSAGES_ACTIONS:
118-
self._maximum_per_channel = FetchMessages.MAX_MESSAGES_ACTIONS
119-
logger.info("maximum_per_channel param defaulting to %d", FetchMessages.DEFAULT_MESSAGES)
119+
if self._count is None or self._count < 1 or\
120+
self._count > FetchMessages.MAX_MESSAGES_ACTIONS:
121+
self._count = FetchMessages.MAX_MESSAGES_ACTIONS
122+
logger.info("count param defaulting to %d", FetchMessages.MAX_MESSAGES_ACTIONS)
120123

121124
def create_response(self, envelope): # pylint: disable=W0221
122125
return PNFetchMessagesResult.from_json(

pubnub/pubnub_core.py

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

5757
class PubNubCore:
5858
"""A base class for PubNub Python API implementations"""
59-
SDK_VERSION = "4.5.1"
59+
SDK_VERSION = "4.5.2"
6060
SDK_NAME = "PubNub-Python"
6161

6262
TIMESTAMP_DIVIDER = 1000

setup.py

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

33
setup(
44
name='pubnub',
5-
version='4.5.1',
5+
version='4.5.2',
66
description='PubNub Real-time push service in the cloud',
77
author='PubNub',
88
author_email='[email protected]',

0 commit comments

Comments
 (0)