api: Fix call_on_each_events handling of empty event_types.
The root issue here is that we had been using `None` as a way of encoding `event_types` as being an argument to not pass to the server in the API codebase, but the marshalling to send this over the wire didn't handle that possibility correctly. This was incorrectly "fixed" in 409bb587429ec4dcb1220a8ed85ec1618ffde0ed; the root cause of the issue was the refactor to the new approach for registering API endpoints.
This commit is contained in:
parent
0f448579ab
commit
d40328a311
|
@ -580,8 +580,12 @@ class Client(object):
|
||||||
# type: (Optional[str], str, Optional[Dict[str, Any]], bool, Optional[List[IO[Any]]]) -> Dict[str, Any]
|
# type: (Optional[str], str, Optional[Dict[str, Any]], bool, Optional[List[IO[Any]]]) -> Dict[str, Any]
|
||||||
if request is None:
|
if request is None:
|
||||||
request = dict()
|
request = dict()
|
||||||
|
marshalled_request = {}
|
||||||
|
for (k, v) in request.items():
|
||||||
|
if v is not None:
|
||||||
|
marshalled_request[k] = v
|
||||||
versioned_url = API_VERSTRING + (url if url is not None else "")
|
versioned_url = API_VERSTRING + (url if url is not None else "")
|
||||||
return self.do_api_query(request, versioned_url, method=method,
|
return self.do_api_query(marshalled_request, versioned_url, method=method,
|
||||||
longpolling=longpolling, files=files)
|
longpolling=longpolling, files=files)
|
||||||
|
|
||||||
def call_on_each_event(self, callback, event_types=None, narrow=None):
|
def call_on_each_event(self, callback, event_types=None, narrow=None):
|
||||||
|
@ -709,9 +713,6 @@ class Client(object):
|
||||||
if narrow is None:
|
if narrow is None:
|
||||||
narrow = []
|
narrow = []
|
||||||
|
|
||||||
if event_types is None:
|
|
||||||
event_types = []
|
|
||||||
|
|
||||||
request = dict(
|
request = dict(
|
||||||
event_types=event_types,
|
event_types=event_types,
|
||||||
narrow=narrow,
|
narrow=narrow,
|
||||||
|
|
|
@ -43,7 +43,7 @@ options = parser.parse_args()
|
||||||
client = zulip.init_from_options(options)
|
client = zulip.init_from_options(options)
|
||||||
|
|
||||||
request = {
|
request = {
|
||||||
'narrow': [["stream", "Denmark"]],
|
'narrow': [["pm-with", "rishig@zulipchat.com"]],
|
||||||
'num_before': options.count,
|
'num_before': options.count,
|
||||||
'num_after': 0,
|
'num_after': 0,
|
||||||
'anchor': 1000000000,
|
'anchor': 1000000000,
|
||||||
|
|
Loading…
Reference in a new issue