compatibility: Require version 16.2.96+ for our Android app.

This release is from 2018-08-22, a little over 100 days ago.

It was the first release with the important fix so that when the
server advises it to stop displaying a notification because the user
has read the message (as the SEND_REMOVE_PUSH_NOTIFICATIONS server
setting enables), the app doesn't instead replace the notification
with a broken one reading "null".  We have that setting running now
on chat.zulip.org, and intend to roll it out more broadly soon.

The `# take 0` thing is a slightly absurd workaround for the fact
that our funky out-of-line way of marking lines to ignore doesn't
work right if there are multiple such lines in a given file that
are equal modulo leading and trailing whitespace.
This commit is contained in:
Greg Price
2018-12-04 15:49:23 -08:00
committed by Tim Abbott
parent 0fa4fdcff9
commit fb7bfbe9ab
3 changed files with 21 additions and 2 deletions

View File

@@ -501,6 +501,7 @@ def build_custom_checkers(by_lang):
'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 _()'},

View File

@@ -64,5 +64,12 @@ class CompatibilityTest(ZulipTestCase):
def get(user_agent: str) -> HttpResponse:
return self.client_get("/compatibility", HTTP_USER_AGENT=user_agent)
self.assert_json_success(get('ZulipMobile/5.0'))
self.assert_json_error(get('ZulipInvalid/5.0'), "Client is too old")
self.assert_json_success(get('ZulipMobile/5.0'))
self.assert_json_success(get('ZulipMobile/5.0 (iOS 11)'))
self.assert_json_success(get('ZulipMobile/5.0 (Androidish 9)'))
self.assert_json_error(get('ZulipMobile/5.0 (Android 9)'), "Client is too old")
self.assert_json_error(get('ZulipMobile/15.1.95 (Android 9)'), "Client is too old")
self.assert_json_error(get('ZulipMobile/16.1.94 (Android 9)'), "Client is too old")
self.assert_json_success(get('ZulipMobile/16.2.96 (Android 9)'))
self.assert_json_success(get('ZulipMobile/20.0.103 (Android 9)'))

View File

@@ -64,8 +64,19 @@ def find_mobile_os(user_agent: str) -> Optional[str]:
return None
# 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:
user_agent = parse_user_agent(request.META["HTTP_USER_AGENT"])
if user_agent['name'] == "ZulipInvalid":
return json_error("Client is too old")
return json_error("Client is too old") # take 0
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_success()