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)
This commit is contained in:
parent
5af50391b2
commit
65e6a35f63
|
@ -250,13 +250,13 @@ class Client(object):
|
||||||
call.func_name = name
|
call.func_name = name
|
||||||
setattr(cls, name, call)
|
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():
|
def do_register():
|
||||||
while True:
|
while True:
|
||||||
if event_types is None:
|
if event_types is None:
|
||||||
res = self.register()
|
res = self.register()
|
||||||
else:
|
else:
|
||||||
res = self.register(event_types=event_types)
|
res = self.register(event_types=event_types, narrow=narrow)
|
||||||
|
|
||||||
if 'error' in res.get('result'):
|
if 'error' in res.get('result'):
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
|
@ -318,10 +318,10 @@ def _mk_rm_subs(streams):
|
||||||
def _mk_deregister(queue_id):
|
def _mk_deregister(queue_id):
|
||||||
return {'queue_id': 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:
|
if event_types is None:
|
||||||
return dict()
|
return dict()
|
||||||
return dict(event_types=event_types)
|
return dict(event_types=event_types, narrow=narrow)
|
||||||
|
|
||||||
def _kwargs_to_dict(**kwargs):
|
def _kwargs_to_dict(**kwargs):
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
Loading…
Reference in a new issue