mirror of https://github.com/zulip/zulip.git
signals: Fix browser reporting for new Electron logins.
Previously, we were checking for "Zulip" entries in User-Agent strings at the very end of the list, not the beginning. A Zulip User-Agent should have priority, since it includes the User-Agent strings for a lot of other browsers, and also it will always be the most specific value.
This commit is contained in:
parent
d3d6712fa3
commit
59d2eae946
|
@ -13,7 +13,9 @@ from zerver.models import UserProfile
|
|||
def get_device_browser(user_agent):
|
||||
# type: (str) -> Optional[str]
|
||||
user_agent = user_agent.lower()
|
||||
if "edge" in user_agent:
|
||||
if "zulip" in user_agent:
|
||||
return "Zulip"
|
||||
elif "edge" in user_agent:
|
||||
return "Edge"
|
||||
elif "opera" in user_agent or "opr/" in user_agent:
|
||||
return "Opera"
|
||||
|
@ -27,8 +29,6 @@ def get_device_browser(user_agent):
|
|||
return "Safari"
|
||||
elif "msie" in user_agent or "trident" in user_agent:
|
||||
return "Internet Explorer"
|
||||
elif "zulip" in user_agent:
|
||||
return "Zulip"
|
||||
else:
|
||||
return None
|
||||
|
||||
|
|
|
@ -89,6 +89,9 @@ class TestBrowserAndOsUserAgentStrings(ZulipTestCase):
|
|||
'Version/10.0.2 Safari/602.3.12', 'Safari', 'MacOS'),
|
||||
('ZulipAndroid/1.0', 'Zulip', 'Android'),
|
||||
('ZulipMobile/1.0', 'Zulip', None),
|
||||
('ZulipElectron/1.1.0-beta Mozilla/5.0 (Windows NT 10.0; Win64; x64) ' +
|
||||
'AppleWebKit/537.36 (KHTML, like Gecko) Zulip/1.1.0-beta ' +
|
||||
'Chrome/56.0.2924.87 Electron/1.6.8 Safari/537.36', 'Zulip', 'Windows'),
|
||||
('Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.7 (KHTML, '
|
||||
'like Gecko) Ubuntu/11.10 Chromium/16.0.912.77 '
|
||||
'Chrome/16.0.912.77 Safari/535.7', 'Chromium', 'Linux'),
|
||||
|
|
Loading…
Reference in New Issue