From d40328a3116e57b14538a4ebbc815de7486df753 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 25 Apr 2018 22:57:30 -0700 Subject: [PATCH] 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. --- zulip/zulip/__init__.py | 9 +++++---- zulip/zulip/examples/recent-messages | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/zulip/zulip/__init__.py b/zulip/zulip/__init__.py index 824bed2..7269865 100644 --- a/zulip/zulip/__init__.py +++ b/zulip/zulip/__init__.py @@ -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, diff --git a/zulip/zulip/examples/recent-messages b/zulip/zulip/examples/recent-messages index 9525599..176ca49 100755 --- a/zulip/zulip/examples/recent-messages +++ b/zulip/zulip/examples/recent-messages @@ -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,