diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2021-01-12 12:34:16 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-12 12:34:16 +0000 |
commit | 2ec8ca5e6046b207eabe008101631b978758ac6d (patch) | |
tree | 009a9eceb2fa4b08132536b7412213379ef9340f /synapse/api | |
parent | Also support remote users on the joined_rooms admin API. (#8948) (diff) | |
download | synapse-2ec8ca5e6046b207eabe008101631b978758ac6d.tar.xz |
Remove SynapseRequest.get_user_agent (#9069)
SynapseRequest is in danger of becoming a bit of a dumping-ground for "useful stuff relating to Requests", which isn't really its intention (its purpose is to override render, finished and connectionLost to set up the LoggingContext and write the right entries to the request log). Putting utility functions inside SynapseRequest means that lots of our code ends up requiring a SynapseRequest when there is nothing synapse-specific about the Request at all, and any old twisted.web.iweb.IRequest will do. This increases code coupling and makes testing more difficult. In short: move get_user_agent out to a utility function.
Diffstat (limited to 'synapse/api')
-rw-r--r-- | synapse/api/auth.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/synapse/api/auth.py b/synapse/api/auth.py index 48c4d7b0be..6d6703250b 100644 --- a/synapse/api/auth.py +++ b/synapse/api/auth.py @@ -33,6 +33,7 @@ from synapse.api.errors import ( from synapse.api.room_versions import KNOWN_ROOM_VERSIONS from synapse.appservice import ApplicationService from synapse.events import EventBase +from synapse.http import get_request_user_agent from synapse.http.site import SynapseRequest from synapse.logging import opentracing as opentracing from synapse.storage.databases.main.registration import TokenLookupResult @@ -187,7 +188,7 @@ class Auth: """ try: ip_addr = self.hs.get_ip_from_request(request) - user_agent = request.get_user_agent("") + user_agent = get_request_user_agent(request) access_token = self.get_access_token_from_request(request) |