Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3506671
D7271.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
D7271.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D7271: [native] Pass a referrer to Google Play
Attached
Detach File
Event Timeline
Log In to Comment