push notifs: Add a diagnostic in API of whether push notifs enabled.

When the answer is False, this will allow the mobile app to show a
warning that push notifications will not work and the server admin
should set them up.

Based partly on Kunal's PR #7810.  Provides the necessary backend API
for zulip/zulip-mobile#1507.
This commit is contained in:
Greg Price
2018-02-12 14:34:59 -08:00
parent cc1d64edf8
commit ecbc72b857
4 changed files with 28 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ from zerver.context_processors import zulip_default_context, get_realm_from_requ
from zerver.forms import HomepageForm, OurAuthenticationForm, \
WRONG_SUBDOMAIN_ERROR, ZulipPasswordResetForm
from zerver.lib.mobile_auth_otp import is_valid_otp, otp_encrypt_api_key
from zerver.lib.push_notifications import push_notifications_enabled
from zerver.lib.request import REQ, has_request_variables, JsonableError
from zerver.lib.response import json_success, json_error
from zerver.lib.subdomains import get_subdomain, is_subdomain_root_or_alias
@@ -713,6 +714,7 @@ def api_get_server_settings(request: HttpRequest) -> HttpResponse:
result = dict(
authentication_methods=get_auth_backends_data(request),
zulip_version=ZULIP_VERSION,
push_notifications_enabled=push_notifications_enabled(),
)
context = zulip_default_context(request)
# IMPORTANT NOTE: