Skip to content

Commit 76aad61

Browse files
authored
smp server: update server page for short links to correctly change URI for apps (#1511)
* smp server: update server page for short links to correctly change URI for apps * change page titles
1 parent 37ce109 commit 76aad61

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

apps/smp-server/static/link.html

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@
142142
class="hidden xl:block h-screen pt-[66px] bg-white dark:bg-gradient-radial-mobile dark:lg:bg-gradient-radial">
143143
<div class="container m-auto h-full flex items-center justify-between px-5">
144144
<div class="flex flex-col items-start justify-center w-full">
145-
<h1 class="text-[38px] leading-[43px] font-bold max-w-[500px] mb-[30px] primary-header-contact">You received a
146-
1-time link to connect on SimpleX Chat</h1>
145+
<h1 class="text-[38px] leading-[43px] font-bold max-w-[500px] mb-[30px] primary-header-contact">This is a one-time link of the SimpleX&nbsp;network user</h1>
147146
<h2
148147
class="text-[20px] leading-[28px] text-[#606C71] dark:text-white font-bold max-w-[475px] mb-[80px] secondary-header-contact">
149148
Scan the QR code with the SimpleX Chat app on your phone or tablet.</h2>
@@ -184,10 +183,8 @@ <h1 class="text-[38px] leading-[43px] font-bold max-w-[500px] mb-[30px] primary-
184183
class="block xl:hidden pt-[106px] py-[90px] bg-white dark:bg-gradient-radial-mobile dark:lg:bg-gradient-radial">
185184
<div class="container m-auto px-5">
186185
<div class="flex flex-col items-center">
187-
<h1 class="text-[28px] font-bold text-center max-w-[602px] mb-[40px] primary-header-contact">You received a
188-
1-time link to connect on SimpleX Chat</h1>
189-
<p class="text-[20px] leading-[28px] text-grey-black dark:text-white font-medium mb-[30px]">To make a
190-
connection:</p>
186+
<h1 class="text-[28px] font-bold text-center max-w-[602px] mb-[40px] primary-header-contact">This is a one-time link of the SimpleX&nbsp;network user</h1>
187+
<p class="text-[20px] leading-[28px] text-grey-black dark:text-white font-medium mb-[30px]">To make a connection:</p>
191188
<div
192189
class="flex flex-col justify-center items-center p-4 w-full max-w-[468px] min-h-[131px] rounded-[30px] border-[1px] border-[#A8B0B4] dark:border-white border-opacity-60 mb-6 relative">
193190
<p class="text-xl font-medium text-grey-black dark:text-white mb-4">Install SimpleX app</p>
@@ -506,13 +503,15 @@ <h2 class="text-xl font-bold">If you already installed SimpleX Chat for the term
506503
const url = window.location.href
507504
const messageElements = document.getElementsByClassName('primary-header-contact')
508505

509-
if (url.includes('/invitation')) {
510-
for (let element of messageElements) {
511-
element.textContent = 'You received a 1-time link to connect on SimpleX Chat'
512-
}
513-
} else {
514-
for (let element of messageElements) {
515-
element.textContent = 'You received an address to connect on SimpleX Chat'
506+
for (let element of messageElements) {
507+
if (url.includes('/g') || url.includes('&data=%7B%22groupLinkId%22%3A')) {
508+
element.innerHTML = 'This is a public group address on SimpleX&nbsp;network'
509+
} else if (url.includes('/a') || url.includes('/contact')) {
510+
element.innerHTML = 'This is a public address of the SimpleX&nbsp;network user'
511+
} else if (url.includes('/i') || url.includes('/invitation')) {
512+
element.innerHTML = 'This is a one-time link of the SimpleX&nbsp;network user'
513+
} else if (url.includes('/c')) {
514+
element.innerHTML = 'This is a public channel address on SimpleX&nbsp;network'
516515
}
517516
}
518517
</script>

apps/smp-server/static/media/contact.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,18 @@
2020
parsedURI.pathname = "/" + action
2121
connURI = parsedURI.toString()
2222
console.log("connection URI: ", connURI)
23-
mobileConnURIanchor.href = "simplex:" + parsedURI.pathname + parsedURI.hash
23+
const hash = parsedURI.hash
24+
const hostname = parsedURI.hostname
25+
let appURI = "simplex:" + parsedURI.pathname
26+
appURI += action.length > 1 // not short link
27+
? hash
28+
: !hash.includes("?") // otherwise add server hostname
29+
? hash + "?h=" + hostname // no parameters
30+
: !hash.includes("?h=") && !hash.includes("&h=")
31+
? hash + "&h=" + hostname // no "h" parameter
32+
: hash.replace(/([?&])h=([^&]+)/, `$1h=${hostname},$2`) // add as the first hostname to "h" parameter
33+
mobileConnURIanchor.href = appURI
34+
console.log("app URI: ", appURI)
2435
connURIel.innerText = "/c " + connURI
2536
for (const connQRCode of connQRCodes) {
2637
try {

apps/smp-server/web/Static.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ generateSite si onionHost sitePath = do
8888
createLinkPage "invitation"
8989
createLinkPage "a"
9090
createLinkPage "c"
91+
createLinkPage "g"
9192
createLinkPage "i"
9293
logInfo $ "Generated static site contents at " <> tshow sitePath
9394
where

0 commit comments

Comments
 (0)