2018-06-28 06:47:06 +00:00
|
|
|
var express = require('express');
|
|
|
|
var assetLinks = require('../resources/assetlinks.json');
|
2018-06-28 20:11:45 +00:00
|
|
|
var appleSiteAssociation = require('../resources/apple-app-site-association.json');
|
2018-10-05 05:31:10 +00:00
|
|
|
var { makeQrCodeDataUri } = require('../utils/qrcodeUtils');
|
|
|
|
|
|
|
|
var router = express.Router();
|
2018-06-28 06:47:06 +00:00
|
|
|
|
2018-07-02 18:48:58 +00:00
|
|
|
router.get('/', function (req, res, next) {
|
2018-07-02 13:07:23 +00:00
|
|
|
function isAndroid(userAgent) {
|
|
|
|
return userAgent.toLowerCase().indexOf("android") > -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
function isIOS(userAgent) {
|
|
|
|
return userAgent.toLowerCase().indexOf("iphone") > -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (req.query.redirect) {
|
2018-07-03 06:26:25 +00:00
|
|
|
return next();
|
2018-07-02 13:07:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var userAgent = req.headers['user-agent'];
|
|
|
|
|
2018-07-03 05:56:55 +00:00
|
|
|
res.header('Cache-Control', 'private, no-cache, no-store, must-revalidate');
|
|
|
|
res.header('Expires', '-1');
|
|
|
|
res.header('Pragma', 'no-cache');
|
|
|
|
|
2018-07-02 13:07:23 +00:00
|
|
|
if (isAndroid(userAgent)) {
|
2018-07-03 06:26:25 +00:00
|
|
|
return res.redirect("https://play.google.com/store/apps/details?id=im.status.ethereum");
|
2018-07-02 13:07:23 +00:00
|
|
|
} else if (isIOS(userAgent)) {
|
2018-09-26 17:55:22 +00:00
|
|
|
return res.redirect("https://testflight.apple.com/join/J8EuJmey");
|
2018-07-02 13:07:23 +00:00
|
|
|
}
|
|
|
|
|
2018-07-03 06:26:25 +00:00
|
|
|
return res.redirect("https://status.im");
|
|
|
|
});
|
2018-07-02 13:07:23 +00:00
|
|
|
|
2018-06-28 11:15:04 +00:00
|
|
|
router.get('/health', function(req, res) {
|
|
|
|
res.send('OK');
|
|
|
|
});
|
2018-06-28 06:47:06 +00:00
|
|
|
|
|
|
|
router.get('/.well-known/assetlinks.json', function(req, res) {
|
|
|
|
res.json(assetLinks);
|
|
|
|
});
|
|
|
|
|
2018-06-28 20:11:45 +00:00
|
|
|
router.get('/.well-known/apple-app-site-association', function(req, res) {
|
|
|
|
res.json(appleSiteAssociation);
|
|
|
|
});
|
|
|
|
|
2018-07-02 18:48:58 +00:00
|
|
|
router.get('/chat/:chatType/:chatId', function(req, res, next) {
|
2018-07-03 06:26:25 +00:00
|
|
|
const { chatId, chatType } = req.params;
|
2018-06-28 06:47:06 +00:00
|
|
|
res.render('index', {
|
2018-07-03 06:26:25 +00:00
|
|
|
title: `Join the ${chatType} chat: #${chatId} in Status`,
|
2020-02-10 18:17:55 +00:00
|
|
|
path: req.originalUrl,
|
|
|
|
id: `${chatId}`
|
2018-06-28 06:47:06 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-02 18:48:58 +00:00
|
|
|
router.get('/user/:userId', function(req, res, next) {
|
2018-10-05 05:31:10 +00:00
|
|
|
const { userId } = req.params;
|
|
|
|
const options = {
|
|
|
|
title: `View user ${userId} profile in Status`,
|
|
|
|
path: req.originalUrl,
|
2020-02-10 18:17:55 +00:00
|
|
|
id: `${userId}`
|
2018-10-05 05:31:10 +00:00
|
|
|
};
|
|
|
|
makeQrCodeDataUri(userId).then(
|
|
|
|
qrCodeDataUri => res.render('index', { ...options, qrCodeDataUri }),
|
|
|
|
error => res.render('index', options)
|
|
|
|
);
|
2018-06-28 07:27:15 +00:00
|
|
|
});
|
|
|
|
|
2018-12-01 18:56:51 +00:00
|
|
|
router.get('/extension/:extensionEndpoint', function(req, res, next) {
|
|
|
|
const { extensionEndpoint } = req.params;
|
|
|
|
const options = {
|
|
|
|
title: `Open extension ${extensionEndpoint} in Status`,
|
|
|
|
path: req.originalUrl,
|
2020-02-10 18:17:55 +00:00
|
|
|
id: `${extensionEndpoint}`
|
2018-12-01 18:56:51 +00:00
|
|
|
};
|
|
|
|
makeQrCodeDataUri('https://get.status.im/extension/' + extensionEndpoint).then(
|
|
|
|
qrCodeDataUri => res.render('index', { ...options, qrCodeDataUri }),
|
|
|
|
error => res.render('index', options)
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2018-07-05 09:28:59 +00:00
|
|
|
router.get('/browse/:url(*)', function(req, res, next) {
|
2018-06-28 07:27:15 +00:00
|
|
|
res.render('index', {
|
2018-07-03 06:26:25 +00:00
|
|
|
title: `Browse to ${req.params.url} in Status`,
|
2020-02-10 18:17:55 +00:00
|
|
|
path: req.originalUrl,
|
|
|
|
id: `${req.params.url}`
|
2018-06-28 06:47:06 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = router;
|