Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
31 lines
1.4 KiB
Python
31 lines
1.4 KiB
Python
from django.http import HttpRequest, HttpResponse
|
|
from django.utils.translation import gettext as _
|
|
|
|
from zerver.lib.compatibility import find_mobile_os, version_lt
|
|
from zerver.lib.exceptions import JsonableError
|
|
from zerver.lib.response import json_success
|
|
from zerver.lib.user_agent import parse_user_agent
|
|
|
|
# Zulip Mobile release 16.2.96 was made 2018-08-22. It fixed a
|
|
# bug in our Android code that causes spammy, obviously-broken
|
|
# notifications once the "remove_push_notification" feature is
|
|
# enabled on the user's Zulip server.
|
|
android_min_app_version = "16.2.96"
|
|
|
|
|
|
def check_global_compatibility(request: HttpRequest) -> HttpResponse:
|
|
if "User-Agent" not in request.headers:
|
|
raise JsonableError(_("User-Agent header missing from request"))
|
|
|
|
# This string should not be tagged for translation, since old
|
|
# clients are checking for an extra string.
|
|
legacy_compatibility_error_message = "Client is too old"
|
|
user_agent = parse_user_agent(request.headers["User-Agent"])
|
|
if user_agent["name"] == "ZulipInvalid":
|
|
raise JsonableError(legacy_compatibility_error_message)
|
|
if user_agent["name"] == "ZulipMobile":
|
|
user_os = find_mobile_os(request.headers["User-Agent"])
|
|
if user_os == "android" and version_lt(user_agent["version"], android_min_app_version):
|
|
raise JsonableError(legacy_compatibility_error_message)
|
|
return json_success(request)
|