mirror of
https://github.com/zulip/zulip.git
synced 2026-07-15 21:03:26 +08:00
Add a query to fetch the subscribers of a stream
(imported from commit 286bb42980619a3f8e575a4e2984ad1c4b3fe099)
This commit is contained in:
parent
f5e25d2e64
commit
45de8fd25b
@ -56,6 +56,7 @@ urlpatterns = patterns('',
|
||||
url(r'^json/subscriptions/add$', 'zephyr.views.json_add_subscriptions'),
|
||||
url(r'^json/subscriptions/exists$', 'zephyr.views.json_stream_exists'),
|
||||
url(r'^json/subscriptions/property$', 'zephyr.views.json_subscription_property'),
|
||||
url(r'^json/get_subscribers$', 'zephyr.views.json_get_subscribers'),
|
||||
url(r'^json/fetch_api_key$', 'zephyr.views.json_fetch_api_key'),
|
||||
|
||||
# These are json format views used by the API. They require an API key.
|
||||
@ -66,6 +67,7 @@ urlpatterns = patterns('',
|
||||
url(r'^api/v1/subscriptions/list$', 'zephyr.views.api_list_subscriptions'),
|
||||
url(r'^api/v1/subscriptions/add$', 'zephyr.views.api_add_subscriptions'),
|
||||
url(r'^api/v1/subscriptions/remove$', 'zephyr.views.api_remove_subscriptions'),
|
||||
url(r'^api/v1/get_subscribers$', 'zephyr.views.api_get_subscribers'),
|
||||
url(r'^api/v1/send_message$', 'zephyr.views.api_send_message'),
|
||||
url(r'^api/v1/update_pointer$', 'zephyr.views.api_update_pointer'),
|
||||
url(r'^api/v1/external/github$', 'zephyr.views.api_github_landing'),
|
||||
|
||||
@ -831,6 +831,30 @@ def add_subscriptions_backend(request, user_profile,
|
||||
|
||||
return json_success(result)
|
||||
|
||||
@authenticated_api_view
|
||||
def api_get_subscribers(request, user_profile):
|
||||
return get_subscribers_backend(request, user_profile)
|
||||
|
||||
@authenticated_json_post_view
|
||||
def json_get_subscribers(request, user_profile):
|
||||
return get_subscribers_backend(request, user_profile)
|
||||
|
||||
@has_request_variables
|
||||
def get_subscribers_backend(request, user_profile, stream_name=POST('stream')):
|
||||
if user_profile.realm.domain == "mit.edu":
|
||||
return json_error("You cannot get subscribers in this realm")
|
||||
|
||||
try:
|
||||
stream = Stream.objects.get(name=stream_name, realm=user_profile.realm)
|
||||
except Stream.DoesNotExist:
|
||||
return json_error("Stream does not exist: %s" % stream_name)
|
||||
subscriptions = Subscription.objects.filter(recipient__type=Recipient.STREAM,
|
||||
recipient__type_id=stream.id,
|
||||
active=True).select_related()
|
||||
|
||||
return json_success({'subscribers': [subscription.user_profile.user.email
|
||||
for subscription in subscriptions]})
|
||||
|
||||
@authenticated_json_post_view
|
||||
@has_request_variables
|
||||
def json_change_settings(request, user_profile, full_name=POST,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user