From 0b9ea4db0530702cef0a21d3757b57c3ccbf76dc Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 22 Aug 2013 11:37:02 -0400 Subject: [PATCH] [manual] Extend /api/v1/streams API endpoint. Previously it only provided the list of all public streams; now it allows one to specify any union of some of the following: * all public streams * all streams the user subscribed to (the most relevant being the union of those two, which is what we want for the "streams" page). Or: * all streams in realm (superuser only) The manual task required is that when this is pushed to prod, we need to also deploy the new sync-public-streams version to zmirror. (imported from commit 27848b8bd136e2777f399b7d05b2fdcec35e4e21) --- bots/sync-public-streams | 2 +- examples/get-public-streams | 2 +- zulip/__init__.py | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bots/sync-public-streams b/bots/sync-public-streams index 9c66db3..d2ddaf7 100755 --- a/bots/sync-public-streams +++ b/bots/sync-public-streams @@ -16,7 +16,7 @@ def fetch_public_streams(): public_streams = set() try: - res = zulip_client.get_public_streams() + res = zulip_client.get_streams(include_all_active=True) if res.get("result") == "success": streams = res["streams"] else: diff --git a/examples/get-public-streams b/examples/get-public-streams index 6eeed50..ea2cc82 100755 --- a/examples/get-public-streams +++ b/examples/get-public-streams @@ -43,4 +43,4 @@ parser.add_option_group(zulip.generate_option_group(parser)) client = zulip.init_from_options(options) -print client.get_public_streams() +print client.get_streams(include_public=True, include_subscribed=False) diff --git a/zulip/__init__.py b/zulip/__init__.py index 7510cb0..25de07e 100644 --- a/zulip/__init__.py +++ b/zulip/__init__.py @@ -286,13 +286,16 @@ def _mk_events(event_types=None): return dict() return dict(event_types=event_types) +def _kwargs_to_dict(**kwargs): + return kwargs + Client._register('send_message', url='messages', make_request=(lambda request: request)) Client._register('update_message', method='PATCH', url='messages', make_request=(lambda request: request)) Client._register('get_messages', method='GET', url='messages/latest', longpolling=True) Client._register('get_events', url='events', method='GET', longpolling=True, make_request=(lambda **kwargs: kwargs)) Client._register('register', make_request=_mk_events) Client._register('get_profile', method='GET', url='users/me') -Client._register('get_public_streams', method='GET', url='streams') +Client._register('get_streams', method='GET', url='streams', make_request=_kwargs_to_dict) Client._register('get_members', method='GET', url='users') Client._register('list_subscriptions', method='GET', url='users/me/subscriptions') Client._register('add_subscriptions', url='users/me/subscriptions', make_request=_mk_subs)