diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py index bdf2bbc124..07e1e3ac6f 100644 --- a/tools/linter_lib/custom_check.py +++ b/tools/linter_lib/custom_check.py @@ -499,11 +499,6 @@ def build_custom_checkers(by_lang): 'bad_lines': ['return json_error(_variable)', 'return json_error(_(variable))']}, {'pattern': r'''\Wjson_error\(['"].+[),]$''', 'exclude': set(['zerver/tests']), - 'exclude_line': set([ - # We don't want this string tagged for translation. - ('zerver/views/compatibility.py', 'return json_error("Client is too old") # take 0'), - ('zerver/views/compatibility.py', 'return json_error("Client is too old")'), - ]), 'description': 'Argument to json_error should a literal string enclosed by _()'}, # To avoid JsonableError(_variable) and JsonableError(_(variable)) {'pattern': r'\WJsonableError\(_\(?\w.+\)', diff --git a/zerver/views/compatibility.py b/zerver/views/compatibility.py index ae64d74ebc..6b2e9f23e6 100644 --- a/zerver/views/compatibility.py +++ b/zerver/views/compatibility.py @@ -71,12 +71,15 @@ def find_mobile_os(user_agent: str) -> Optional[str]: android_min_app_version = '16.2.96' def check_global_compatibility(request: HttpRequest) -> HttpResponse: + # 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.META["HTTP_USER_AGENT"]) if user_agent['name'] == "ZulipInvalid": - return json_error("Client is too old") # take 0 + return json_error(legacy_compatibility_error_message) if user_agent['name'] == "ZulipMobile": user_os = find_mobile_os(request.META["HTTP_USER_AGENT"]) if (user_os == 'android' and version_lt(user_agent['version'], android_min_app_version)): - return json_error("Client is too old") + return json_error(legacy_compatibility_error_message) return json_success()