decorator: Rename remote_server_request to skip_update_user_activity.

This makes it reasonable to call process_client from other contexts,
like /server_settings, where we don't have an authenticated
UserProfile object.
This commit is contained in:
Tim Abbott 2018-12-11 11:09:11 -08:00
parent 0d48f47eba
commit 88368996fb
1 changed files with 4 additions and 3 deletions

View File

@ -181,13 +181,13 @@ def get_client_name(request: HttpRequest, is_browser_view: bool) -> str:
def process_client(request: HttpRequest, user_profile: UserProfile,
*, is_browser_view: bool=False,
client_name: Optional[str]=None,
remote_server_request: bool=False,
skip_update_user_activity: bool=False,
query: Optional[str]=None) -> None:
if client_name is None:
client_name = get_client_name(request, is_browser_view)
request.client = get_client(client_name)
if not remote_server_request:
if not skip_update_user_activity:
update_user_activity(request, user_profile, query)
class InvalidZulipServerError(JsonableError):
@ -227,7 +227,8 @@ def validate_api_key(request: HttpRequest, role: Optional[str],
request.user = remote_server
request._email = "zulip-server:" + role
remote_server.rate_limits = ""
process_client(request, remote_server, remote_server_request=True)
# Skip updating UserActivity, since remote_server isn't actually a UserProfile object.
process_client(request, remote_server, skip_update_user_activity=True)
return remote_server
user_profile = access_user_by_api_key(request, api_key, email=role)