From 65e6a35f63fa840744aafb16045b9948ca09a447 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 10 Dec 2013 10:28:16 -0500 Subject: [PATCH] Add support for event queues with an included narrow. This will allow us to substantially decrease the server-side work that we do to support our Mirroring systems (since the personal mirrors can request only messages that user sent) and also is what we need to support a single-stream Zulip widget that we embed in webpages. (imported from commit 055f2e9a523920719815181f8fdb44d3384e4a34) --- zulip/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zulip/__init__.py b/zulip/__init__.py index c79e84f..56de474 100644 --- a/zulip/__init__.py +++ b/zulip/__init__.py @@ -250,13 +250,13 @@ class Client(object): call.func_name = name setattr(cls, name, call) - def call_on_each_event(self, callback, event_types=None): + def call_on_each_event(self, callback, event_types=None, narrow=[]): def do_register(): while True: if event_types is None: res = self.register() else: - res = self.register(event_types=event_types) + res = self.register(event_types=event_types, narrow=narrow) if 'error' in res.get('result'): if self.verbose: @@ -318,10 +318,10 @@ def _mk_rm_subs(streams): def _mk_deregister(queue_id): return {'queue_id': queue_id} -def _mk_events(event_types=None): +def _mk_events(event_types=None, narrow=[]): if event_types is None: return dict() - return dict(event_types=event_types) + return dict(event_types=event_types, narrow=narrow) def _kwargs_to_dict(**kwargs): return kwargs