From d689e123dd3a87a3b2cc01f0bf7a593aa0e40959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Wed, 19 Feb 2020 18:14:24 +0100 Subject: [PATCH] make button show 'Open in Status' on Android MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit And use the status-im:// URL scheme for the button. Signed-off-by: Jakub SokoĊ‚owski --- routes/index.js | 23 +++++++++++++++++++---- views/index.ejs | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/routes/index.js b/routes/index.js index 3d4eb76..8aba6e9 100644 --- a/routes/index.js +++ b/routes/index.js @@ -39,13 +39,19 @@ router.get('/.well-known/apple-app-site-association', function(req, res) { router.get('/chat/:chatType/:chatId', function(req, res, next) { const { chatId, chatType } = req.params; + /* Make button open chat if on Android */ + let buttonTitle = 'Download Status' + let buttonUrl = 'https://status.im/get/' + if (utils.isAndroid(req.headers['user-agent'])) { + buttonTitle = 'Open in Status' + buttonUrl = `status-im://chat/${chatType}/${chatId}` + } chatName = `#${chatId}`; const options = { title: `Join ${chatType} channel #${chatId} on Status`, info: `Join public channel #${chatId} on Status.`, path: req.originalUrl, - chatId: chatId, - chatName: chatName, + chatId, chatName, buttonTitle, buttonUrl }; utils.makeQrCodeDataUri(chatName).then( qrCodeDataUri => res.render('index', { ...options, qrCodeDataUri }), @@ -55,8 +61,15 @@ router.get('/chat/:chatType/:chatId', function(req, res, next) { router.get('/user/:userId', function(req, res, next) { const { userId } = req.params; - chatName = userId + /* Make button open user profile if on Android */ + let buttonTitle = 'Download Status' + let buttonUrl = 'https://status.im/get/' + if (utils.isAndroid(req.headers['user-agent'])) { + buttonTitle = 'Open in Status' + buttonUrl = `status-im://user/${userId}` + } /* chat keys can be resolved to chat names */ + chatName = userId if (utils.isChatKey(userId)) { chatName = StatusIm.chatKeyToChatName(userId) } @@ -65,7 +78,7 @@ router.get('/user/:userId', function(req, res, next) { info: `Chat and transact with ${userId} in Status.`, path: req.originalUrl, chatId: userId, - chatName: chatName, + chatName, buttonTitle, buttonUrl }; utils.makeQrCodeDataUri(userId).then( qrCodeDataUri => res.render('index', { ...options, qrCodeDataUri }), @@ -81,6 +94,8 @@ router.get('/extension/:extensionEndpoint', function(req, res, next) { path: req.originalUrl, chatId: extensionEndpoint, chatName: extensionEndpoint, + buttonTitle: 'Download Status', + buttonUrl: 'https://status.im/get/', }; utils.makeQrCodeDataUri('https://join.status.im/extension/' + extensionEndpoint).then( qrCodeDataUri => res.render('index', { ...options, qrCodeDataUri }), diff --git a/views/index.ejs b/views/index.ejs index 5c897e5..08ce6ed 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -173,7 +173,7 @@
<%= chatId %>
Copy - Download Status + <%= buttonTitle %>
<%- info %>