Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/responders/website-responders.js
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | |||||
import { | import { | ||||
fetchCurrentUserInfo, | fetchCurrentUserInfo, | ||||
fetchKnownUserInfos, | fetchKnownUserInfos, | ||||
} from '../fetchers/user-fetchers.js'; | } from '../fetchers/user-fetchers.js'; | ||||
import { getWebPushConfig } from '../push/providers.js'; | import { getWebPushConfig } from '../push/providers.js'; | ||||
import { setNewSession } from '../session/cookies.js'; | import { setNewSession } from '../session/cookies.js'; | ||||
import { Viewer } from '../session/viewer.js'; | import { Viewer } from '../session/viewer.js'; | ||||
import { streamJSON, waitForStream } from '../utils/json-stream.js'; | import { streamJSON, waitForStream } from '../utils/json-stream.js'; | ||||
import { getAppURLFactsFromRequestURL } from '../utils/urls.js'; | import { | ||||
getAppURLFactsFromRequestURL, | |||||
getCommAppURLFacts, | |||||
} from '../utils/urls.js'; | |||||
import { validateOutput } from '../utils/validation-utils.js'; | import { validateOutput } from '../utils/validation-utils.js'; | ||||
const { renderToNodeStream } = ReactDOMServer; | const { renderToNodeStream } = ReactDOMServer; | ||||
const access = promisify(fs.access); | const access = promisify(fs.access); | ||||
const readFile = promisify(fs.readFile); | const readFile = promisify(fs.readFile); | ||||
const googleFontsURL = | const googleFontsURL = | ||||
▲ Show 20 Lines • Show All 491 Lines • ▼ Show 20 Lines | const referrer = isSecretValid | ||||
? `&referrer=${encodeURIComponent(`utm_source=invite/${secret}`)}` | ? `&referrer=${encodeURIComponent(`utm_source=invite/${secret}`)}` | ||||
: ''; | : ''; | ||||
const redirectUrl = `${stores.googlePlayUrl}${referrer}`; | const redirectUrl = `${stores.googlePlayUrl}${referrer}`; | ||||
res.writeHead(301, { | res.writeHead(301, { | ||||
Location: redirectUrl, | Location: redirectUrl, | ||||
}); | }); | ||||
res.end(); | res.end(); | ||||
return; | return; | ||||
} else if (detectionResult.os !== 'iOS') { | |||||
const baseRoutePath = getCommAppURLFacts()?.baseRoutePath; | |||||
const redirectUrl = `${baseRoutePath ?? '/'}handle/invite/${secret}`; | |||||
res.writeHead(301, { | |||||
Location: redirectUrl, | |||||
}); | |||||
res.end(); | |||||
return; | |||||
} | } | ||||
const fontsURL = await getFontsURL(); | const fontsURL = await getFontsURL(); | ||||
res.end(html` | res.end(html` | ||||
<!DOCTYPE html> | <!DOCTYPE html> | ||||
<html lang="en"> | <html lang="en"> | ||||
<head> | <head> | ||||
<meta charset="utf-8" /> | <meta charset="utf-8" /> | ||||
<title>Comm</title> | <title>Comm</title> | ||||
▲ Show 20 Lines • Show All 160 Lines • Show Last 20 Lines |