mirror of https://github.com/zulip/zulip.git
get_public_streams: Return only streams someone is subscribed to.
This makes subscribing to zephyr classes for the zephyr class mirroring bot a lot faster, since we don't need to subscribe to the third of our streams on which no users will actually receive messages. (imported from commit 029b7fb260b480db5599e3c9f9effc502f6d8b59)
This commit is contained in:
parent
70a8e51351
commit
79f8e2a6a3
|
@ -699,8 +699,13 @@ def notify_pointer_update(request):
|
|||
|
||||
@authenticated_api_view
|
||||
def api_get_public_streams(request, user_profile):
|
||||
# Only get streams someone is currently subscribed to
|
||||
subs_filter = Subscription.objects.filter(active=True).values('recipient_id')
|
||||
stream_ids = Recipient.objects.filter(
|
||||
type=Recipient.STREAM, id__in=subs_filter).values('type_id')
|
||||
streams = sorted(stream.name for stream in
|
||||
Stream.objects.filter(realm=user_profile.realm))
|
||||
Stream.objects.filter(id__in = stream_ids,
|
||||
realm=user_profile.realm))
|
||||
return json_success({"streams": streams})
|
||||
|
||||
def gather_subscriptions(user_profile):
|
||||
|
|
Loading…
Reference in New Issue