Page MenuHomePhabricator

D7271.diff
No OneTemporary

D7271.diff

diff --git a/keyserver/src/keyserver.js b/keyserver/src/keyserver.js
--- a/keyserver/src/keyserver.js
+++ b/keyserver/src/keyserver.js
@@ -42,6 +42,8 @@
getCommAppURLFacts,
} from './utils/urls.js';
+const inviteSecretRegex = /^[a-z0-9]+$/i;
+
(async () => {
await olm.init();
await prefetchAllURLFacts();
@@ -128,12 +130,17 @@
// should redirect the user to a place from which the app can be
// downloaded.
router.get('/invite/:secret', (req, res) => {
+ const { secret } = req.params;
const userAgent = req.get('User-Agent');
const detectionResult = detectBrowser(userAgent);
- const redirectUrl =
- detectionResult.os === 'Android OS'
- ? stores.googlePlayUrl
- : stores.appStoreUrl;
+ let redirectUrl = stores.appStoreUrl;
+ if (detectionResult.os === 'Android OS') {
+ const isSecretValid = inviteSecretRegex.test(secret);
+ const referrer = isSecretValid
+ ? `&referrer=${encodeURIComponent(`utm_source=invite/${secret}`)}`
+ : '';
+ redirectUrl = `${stores.googlePlayUrl}${referrer}`;
+ }
res.writeHead(301, {
Location: redirectUrl,
});

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 21, 5:48 PM (20 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2688563
Default Alt Text
D7271.diff (1 KB)

Event Timeline