From f9cfa6b5f75aee6c9656baedc3fcdc579e118f03 Mon Sep 17 00:00:00 2001 From: Scott Feeney Date: Fri, 6 Sep 2013 20:20:51 -0400 Subject: [PATCH] Include subscriber list in page_params.stream_list (imported from commit 7f03eec37c7cbdcdefb590c39a76444bd1b55230) --- zerver/lib/actions.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index e3376d6cfb..5481140ba9 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -1283,12 +1283,24 @@ def gather_subscriptions(user_profile): for sub in subs: stream = stream_hash[sub.recipient.type_id] + try: + subscribers = get_subscribers(stream) + except JsonableError: + subscribers = None + + # Important: don't show the subscribers if the stream is invite only + # and this user isn't on it anymore. + if stream.invite_only and not sub.active: + subscribers = None + stream = {'name': stream.name, 'in_home_view': sub.in_home_view, 'invite_only': stream.invite_only, 'color': sub.color, 'notifications': sub.notifications, 'email_address': encode_email_address(stream)} + if subscribers is not None: + stream['subscribers'] = [user.email for user in subscribers] if sub.active: subscribed.append(stream) else: @@ -1402,6 +1414,16 @@ def do_events_register(user_profile, user_client, apply_markdown=True, for sub in ret['subscriptions']: if sub['name'].lower() == event['name'].lower(): sub[event['property']] = event['value'] + elif event['op'] == 'peer_add': + for sub in ret['subscriptions']: + if (sub['name'] in event['subscriptions'] and + event['user_email'] not in sub['subscribers']): + sub['subscribers'].append(event['user_email']) + elif event['op'] == 'peer_remove': + for sub in ret['subscriptions']: + if (sub['name'] in event['subscriptions'] and + event['user_email'] in sub['subscribers']): + sub['subscribers'].remove(event['user_email']) elif event['type'] == "presence": ret['presences'][event['email']] = event['presence'] elif event['type'] == "update_message":