mirror of https://github.com/zulip/zulip.git
middleware: Add client_version attribute to request.
This commit is contained in:
parent
6224d83dea
commit
ac203cd9f1
|
@ -32,6 +32,7 @@ from zerver.lib.request import set_request, unset_request
|
|||
from zerver.lib.response import json_error, json_response_from_error, json_unauthorized
|
||||
from zerver.lib.subdomains import get_subdomain
|
||||
from zerver.lib.types import ViewFuncT
|
||||
from zerver.lib.user_agent import parse_user_agent
|
||||
from zerver.lib.utils import statsd
|
||||
from zerver.models import Realm, flush_per_request_caches, get_realm
|
||||
|
||||
|
@ -291,6 +292,9 @@ class LogRequests(MiddlewareMixin):
|
|||
# method here too
|
||||
def process_user_agent(self, request: HttpRequest) -> None:
|
||||
request.client_name = get_client_name(request)
|
||||
request.client_version = None
|
||||
if request.client_name.startswith("Zulip"):
|
||||
request.client_version = parse_user_agent(request.META["HTTP_USER_AGENT"])["version"]
|
||||
|
||||
def process_request(self, request: HttpRequest) -> None:
|
||||
maybe_tracemalloc_listen()
|
||||
|
|
|
@ -232,6 +232,7 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
|
|||
request.user = old_request.user
|
||||
request.client = old_request.client
|
||||
request.client_name = old_request.client_name
|
||||
request.client_version = old_request.client_version
|
||||
|
||||
# The saved_response attribute, if present, causes
|
||||
# rest_dispatch to return the response immediately before
|
||||
|
|
Loading…
Reference in New Issue