2018-06-28 06:47:06 +00:00
|
|
|
var express = require('express');
|
|
|
|
var router = express.Router();
|
|
|
|
var assetLinks = require('../resources/assetlinks.json');
|
2018-06-28 20:11:45 +00:00
|
|
|
var appleSiteAssociation = require('../resources/apple-app-site-association.json');
|
2018-06-28 06:47:06 +00:00
|
|
|
|
2018-07-02 13:07:23 +00:00
|
|
|
function serverSideRedirect(req, res, next) {
|
|
|
|
function isAndroid(userAgent) {
|
|
|
|
return userAgent.toLowerCase().indexOf("android") > -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
function isIOS(userAgent) {
|
|
|
|
return userAgent.toLowerCase().indexOf("iphone") > -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(req.query);
|
|
|
|
console.log(req.params);
|
|
|
|
console.log(req.queryParams);
|
|
|
|
|
|
|
|
if (req.query.redirect) {
|
|
|
|
return next();
|
|
|
|
}
|
|
|
|
|
|
|
|
var userAgent = req.headers['user-agent'];
|
|
|
|
|
|
|
|
if (isAndroid(userAgent)) {
|
|
|
|
return res.redirect("https://play.google.com/store/apps/details?id=im.status.ethereum");
|
|
|
|
} else if (isIOS(userAgent)) {
|
|
|
|
return res.redirect("https://status.im/success")
|
|
|
|
}
|
|
|
|
|
|
|
|
return res.redirect("https://status.im")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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 13:07:23 +00:00
|
|
|
router.get('/chat/:chatType/:chatId', serverSideRedirect, function(req, res, next) {
|
2018-06-28 06:47:06 +00:00
|
|
|
res.render('index', {
|
|
|
|
title: 'Status.im join ' + req.params.chatId + ' chat',
|
|
|
|
path: req.originalUrl
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-02 13:07:23 +00:00
|
|
|
router.get('/user/:userId', serverSideRedirect, function(req, res, next) {
|
2018-06-28 06:47:06 +00:00
|
|
|
res.render('index', {
|
|
|
|
title: 'Status.im view ' + req.params.userId + ' profile',
|
2018-06-28 07:27:15 +00:00
|
|
|
path: req.originalUrl
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-02 13:07:23 +00:00
|
|
|
router.get('/browse/:url', serverSideRedirect, function(req, res, next) {
|
2018-06-28 07:27:15 +00:00
|
|
|
res.render('index', {
|
|
|
|
title: 'Status.im browse ' + req.params.url + ' dapp',
|
2018-06-28 06:47:06 +00:00
|
|
|
path: req.originalUrl
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = router;
|