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:
Tim Abbott 2018-04-25 22:57:30 -07:00
parent 0f448579ab
commit d40328a311
2 changed files with 6 additions and 5 deletions

View file

@ -580,8 +580,12 @@ class Client(object):
# type: (Optional[str], str, Optional[Dict[str, Any]], bool, Optional[List[IO[Any]]]) -> Dict[str, Any]
if request is None:
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 "")
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)
def call_on_each_event(self, callback, event_types=None, narrow=None):
@ -709,9 +713,6 @@ class Client(object):
if narrow is None:
narrow = []
if event_types is None:
event_types = []
request = dict(
event_types=event_types,
narrow=narrow,

View file

@ -43,7 +43,7 @@ options = parser.parse_args()
client = zulip.init_from_options(options)
request = {
'narrow': [["stream", "Denmark"]],
'narrow': [["pm-with", "rishig@zulipchat.com"]],
'num_before': options.count,
'num_after': 0,
'anchor': 1000000000,