Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3400233
D7240.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D7240.diff
View Options
diff --git a/keyserver/package.json b/keyserver/package.json
--- a/keyserver/package.json
+++ b/keyserver/package.json
@@ -48,6 +48,7 @@
"common-tags": "^1.7.2",
"cookie-parser": "^1.4.3",
"dateformat": "^3.0.3",
+ "detect-browser": "^4.0.4",
"ethers": "^5.7.2",
"express": "^4.17.3",
"express-ws": "^4.0.0",
diff --git a/keyserver/src/keyserver.js b/keyserver/src/keyserver.js
--- a/keyserver/src/keyserver.js
+++ b/keyserver/src/keyserver.js
@@ -3,6 +3,7 @@
import olm from '@matrix-org/olm';
import cluster from 'cluster';
import cookieParser from 'cookie-parser';
+import { detect as detectBrowser } from 'detect-browser';
import express from 'express';
import expressWs from 'express-ws';
import os from 'os';
@@ -127,8 +128,14 @@
// should redirect the user to a place from which the app can be
// downloaded.
router.get('/invite/:secret', (req, res) => {
+ const userAgent = req.get('User-Agent');
+ const detectionResult = detectBrowser(userAgent);
+ const redirectUrl =
+ detectionResult.os === 'Android OS'
+ ? stores.googlePlayUrl
+ : stores.appStoreUrl;
res.writeHead(301, {
- Location: stores.appStoreUrl,
+ Location: redirectUrl,
});
res.end();
});
diff --git a/lib/facts/stores.js b/lib/facts/stores.js
--- a/lib/facts/stores.js
+++ b/lib/facts/stores.js
@@ -2,6 +2,8 @@
const stores = {
appStoreUrl: 'https://apps.apple.com/us/app/comm-messenger/id1574433435',
+ googlePlayUrl:
+ 'https://play.google.com/store/apps/details?id=app.comm.android',
};
export default stores;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 3, 6:41 AM (1 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2610631
Default Alt Text
D7240.diff (1 KB)
Attached To
Mode
D7240: [keyserver] Redirect to the right store depending on the user agent
Attached
Detach File
Event Timeline
Log In to Comment