Skip to content

Commit 7e5d9aa

Browse files
committed
feat: support /u# /c# when parse and gen
1 parent 09df6ac commit 7e5d9aa

File tree

14 files changed

+44
-45
lines changed

14 files changed

+44
-45
lines changed

src/status_im/communities/core.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
(defn universal-link
2525
[community-id]
2626
(str (:external universal-links/domains)
27-
"/c/"
27+
"/c#"
2828
community-id))
2929

3030
(defn <-request-to-join-community-rpc

src/status_im/router/core.cljs

+3-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@
4949
["cr/" :community-id] :community-requests
5050
"g/" group-chat-extractor
5151
["wallet/" :account] :wallet-account
52-
["u/" :user-data] :user}
52+
["u/" :user-data] :user
53+
"c" :community
54+
"u" :user}
5355
ethereum-scheme eip-extractor}])
5456

5557
(defn parse-query-params

src/status_im/router/core_test.cljs

+14
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
:query-params (when (= 3 (count expected)) (last expected))
2020
:uri uri})
2121

22+
"https://status.app/u#zQ3shwQPhRuDJSjVGVBnTjCdgXy5i9WQaeVPdGJD6yTarJQSj"
23+
[:user
24+
{:user-id "zQ3shwQPhRuDJSjVGVBnTjCdgXy5i9WQaeVPdGJD6yTarJQSj"}]
2225
"https://status.app/u/G10A4B0JdgwyRww90WXtnP1oNH1ZLQNM0yX0Ja9YyAMjrqSZIYINOHCbFhrnKRAcPGStPxCMJDSZlGCKzmZrJcimHY8BbcXlORrElv_BbQEegnMDPx1g9C5VVNl0fE4y#zQ3shwQPhRuDJSjVGVBnTjCdgXy5i9WQaeVPdGJD6yTarJQSj"
2326
[:user
2427
{:user-data
@@ -31,6 +34,10 @@
3134
"G10A4B0JdgwyRww90WXtnP1oNH1ZLQNM0yX0Ja9YyAMjrqSZIYINOHCbFhrnKRAcPGStPxCMJDSZlGCKzmZrJcimHY8BbcXlORrElv_BbQEegnMDPx1g9C5VVNl0fE4y"
3235
:user-id "zQ3shwQPhRuDJSjVGVBnTjCdgXy5i9WQaeVPdGJD6yTarJQSj"}]
3336

37+
"status-app://u#zQ3shwQPhRuDJSjVGVBnTjCdgXy5i9WQaeVPdGJD6yTarJQSj"
38+
[:user
39+
{:user-id "zQ3shwQPhRuDJSjVGVBnTjCdgXy5i9WQaeVPdGJD6yTarJQSj"}]
40+
3441
"https://status.app/cc/G54AAKwObLdpiGjXnckYzRcOSq0QQAS_CURGfqVU42ceGHCObstUIknTTZDOKF3E8y2MSicncpO7fTskXnoACiPKeejvjtLTGWNxUhlT7fyQS7Jrr33UVHluxv_PLjV2ePGw5GQ33innzeK34pInIgUGs5RjdQifMVmURalxxQKwiuoY5zwIjixWWRHqjHM=#zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11"
3542
[:community-chat
3643
{:chat-data
@@ -48,13 +55,20 @@
4855
{:community-data
4956
"iyKACkQKB0Rvb2RsZXMSJ0NvbG9yaW5nIHRoZSB3b3JsZCB3aXRoIGpveSDigKIg4bSXIOKAohiYohsiByMxMzFEMkYqAwEhMwM="
5057
:community-id "zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11"}]
58+
"https://status.app/c#zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11"
59+
[:community
60+
{:community-id "zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11"}]
5161

5262
"status-app://c/iyKACkQKB0Rvb2RsZXMSJ0NvbG9yaW5nIHRoZSB3b3JsZCB3aXRoIGpveSDigKIg4bSXIOKAohiYohsiByMxMzFEMkYqAwEhMwM=#zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11"
5363
[:community
5464
{:community-data
5565
"iyKACkQKB0Rvb2RsZXMSJ0NvbG9yaW5nIHRoZSB3b3JsZCB3aXRoIGpveSDigKIg4bSXIOKAohiYohsiByMxMzFEMkYqAwEhMwM="
5666
:community-id "zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11"}]
5767

68+
"status-app://c#zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11"
69+
[:community
70+
{:community-id "zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11"}]
71+
5872
"ethereum:0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7"
5973
[:ethereum {:address "0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7"}]
6074

src/status_im/utils/universal_links/core.cljs

+3-19
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
[status-im.multiaccounts.model :as multiaccounts.model]
99
[status-im.router.core :as router]
1010
[status-im.ui.components.react :as react]
11+
[status-im.utils.universal-links.utils :as universal-links.utils]
1112
[status-im.wallet.choose-recipient.core :as choose-recipient]
1213
[status-im2.constants :as constants]
1314
[status-im2.navigation.events :as navigation]
@@ -27,27 +28,11 @@
2728
(def links
2829
{:private-chat "%s/p/%s"
2930
:community-requests "%s/cr/%s"
30-
:community "%s/c/%s"
31+
:community "%s/c#%s"
3132
:group-chat "%s/g/%s"
32-
:user "%s/u/%s"
33+
:user "%s/u#%s"
3334
:browse "%s/b/%s"})
3435

35-
(defn generate-link
36-
[link-type domain-type param]
37-
(gstring/format (get links link-type)
38-
(get domains domain-type)
39-
param))
40-
41-
(defn universal-link?
42-
[url]
43-
(boolean
44-
(re-matches constants/regx-universal-link url)))
45-
46-
(defn deep-link?
47-
[url]
48-
(boolean
49-
(re-matches constants/regx-deep-link url)))
50-
5136
(rf/defn handle-browse
5237
[cofx {:keys [url]}]
5338
(log/info "universal-links: handling browse" url)
@@ -220,7 +205,6 @@
220205
#_(native-module/start-searching-for-local-pairing-peers
221206
#(log/info "[local-pairing] errors from local-pairing-preflight-outbound-check ->" %)))
222207

223-
224208
(defn finalize
225209
"Remove event listener for url"
226210
[]

src/status_im/utils/universal_links/core_test.cljs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
(is (nil? (get-in (links/handle-url {:db db} "some-url")
2121
[:db :universal-links/url]))))
2222
(testing "Handle a custom string"
23-
(is (= (get-in (links/handle-url {:db db} "https://status.app/u/statuse2e")
23+
(is (= (get-in (links/handle-url {:db db} "https://status.app/u#statuse2e")
2424
[::router/handle-uri :uri])
25-
"https://status.app/u/statuse2e")))))))
25+
"https://status.app/u#statuse2e")))))))
2626

2727
(deftest url-event-listener
2828
(testing "the url is not nil"

src/status_im/utils/universal_links/utils.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
(def links
1212
{:private-chat "%s/p/%s"
13-
:user "%s/u/%s"
13+
:user "%s/u#%s"
1414
:browse "%s/b/%s"})
1515

1616
(defn universal-link?

src/status_im2/contexts/add_new_contact/events.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
(zipmap (repeat nil))))
3535
([kv] (-> (init-contact) (merge kv))))
3636

37-
(def url-regex #"^https?://status.app/u/(.+)")
37+
(def url-regex #"^https?://status.app/u#(.+)")
3838

3939
(defn ->id
4040
[{:keys [input] :as contact}]

src/status_im2/contexts/add_new_contact/events_test.cljs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
(def ckey "zQ3shWj4WaBdf2zYKCkXe6PHxDxNTzZyid1i75879Ue9cX9gA")
1212
(def ens "esep")
1313
(def ens-stateofus-eth (str ens ".stateofus.eth"))
14-
(def link-ckey (str "https://status.app/u/" ckey))
15-
(def link-ens (str "https://status.app/u/" ens))
14+
(def link-ckey (str "https://status.app/u#" ckey))
15+
(def link-ens (str "https://status.app/u#" ens))
1616

1717
;;; unit tests (no app-db involved)
1818

src/status_im2/contexts/add_new_contact/views.cljs

+4-5
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,10 @@
8080
:button (when empty-input?
8181
{:on-press paste-on-input
8282
:text (i18n/label :t/paste)})
83-
;; NOTE: `scanned` has priority over `@input-value`, we clean it when the input
84-
;; is updated so that it's `nil` and `@input-value` is shown.
85-
;; To fastly clean it, we use `dispatch-sync`.
86-
;; This call could be avoided if `::qr-scanner/scan-code` were able to receive a
87-
;; callback function, not only a re-frame event as callback.
83+
;; NOTE: `scanned` has priority over `@input-value`, we clean it when the input is updated
84+
;; so that it's `nil` and `@input-value` is shown. To fastly clean it, we use
85+
;; `dispatch-sync`. This call could be avoided if `::qr-scanner/scan-code` were able to
86+
;; receive a callback function, not only a re-frame event as callback.
8887
:value (or scanned @input-value)
8988
:on-change-text (fn [new-text]
9089
(reset! input-value new-text)

src/status_im2/contexts/chat/messages/link_preview/events.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
(defn community-link
1111
[id]
12-
(str "https://status.app/c/" id))
12+
(str "https://status.app/c#" id))
1313

1414
(rf/defn cache-link-preview-data
1515
{:events [:chat.ui/cache-link-preview-data]}

src/status_im2/contexts/quo_preview/share/share_qr_code.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
[]
1515
(let [state (reagent/atom {:info-button? true
1616
:link-title "Link to profile"
17-
:url "status.app/u/zQ34e1zlOdas0pKnvrweeedsasas12adjie8"})]
17+
:url "status.app/u#zQ34e1zlOdas0pKnvrweeedsasas12adjie8"})]
1818
(fn []
1919
(let [qr-media-server-uri (image-server/get-qr-image-uri-for-any-url
2020
{:url (:url @state)

src/utils/address.cljs

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@
4343

4444
(defn get-abbreviated-profile-url
4545
"The goal here is to generate a string that begins with
46-
status.app/u/ joined with the 1st 5 characters
46+
status.app/u# joined with the 1st 5 characters
4747
of the compressed public key followed by an ellipsis followed by
4848
the last 10 characters of the compressed public key"
4949
[base-url public-key]
50-
(if (and public-key base-url (> (count public-key) 17) (= "status.app/u/" base-url))
50+
(if (and public-key base-url (> (count public-key) 17) (= "status.app/u#" base-url))
5151
(let [first-part-of-public-pk (subs public-key 0 5)
5252
ellipsis "..."
5353
public-key-size (count public-key)

src/utils/address_test.cljs

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@
2222

2323
(deftest test-get-abbreviated-profile-url
2424
(testing "Ensure the function correctly generates an abbreviated profile URL for a valid public key"
25-
(is (= "status.app/u/zQ3sh...mrdYpzeFUa"
25+
(is (= "status.app/u#zQ3sh...mrdYpzeFUa"
2626
(utils.address/get-abbreviated-profile-url
27-
"status.app/u/"
27+
"status.app/u#"
2828
"zQ3shPrnUhhR42JJn3QdhodGest8w8MjiH8hPaimrdYpzeFUa"))))
2929

3030
(testing "Ensure the function returns nil when given an empty public key"
31-
(is (nil? (utils.address/get-abbreviated-profile-url "status.app/u/" ""))))
31+
(is (nil? (utils.address/get-abbreviated-profile-url "status.app/u#" ""))))
3232

3333
(testing "Ensure the function returns nil when given a nil public key"
34-
(is (nil? (utils.address/get-abbreviated-profile-url "status.app/u/" nil))))
34+
(is (nil? (utils.address/get-abbreviated-profile-url "status.app/u#" nil))))
3535

3636
(testing "Ensure the function returns nil when given an incorrect base URL"
3737
(is (nil? (utils.address/get-abbreviated-profile-url
38-
"status.app/uwu/"
38+
"status.app/uwu#"
3939
"zQ3shPrnUhhR42JJn3QdhodGest8w8MjiH8hPaimrdYpzeFUa"))))
4040

4141
(testing "Ensure the function returns nil when given a public key shorter than 17 characters"
42-
(is (nil? (utils.address/get-abbreviated-profile-url "status.app/u/" "abc")))
43-
(is (nil? (utils.address/get-abbreviated-profile-url "status.app/u/" "1234")))))
42+
(is (nil? (utils.address/get-abbreviated-profile-url "status.app/u#" "abc")))
43+
(is (nil? (utils.address/get-abbreviated-profile-url "status.app/u#" "1234")))))

src/utils/image_server.cljs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
(def ^:const account-initials-action "/accountInitials")
1212
(def ^:const contact-images-action "/contactImages")
1313
(def ^:const generate-qr-action "/GenerateQRCode")
14-
(def ^:const status-profile-base-url "https://status.app/u/")
15-
(def ^:const status-profile-base-url-without-https "status.app/u/")
14+
(def ^:const status-profile-base-url "https://status.app/u#")
15+
(def ^:const status-profile-base-url-without-https "status.app/u#")
1616

1717
(defn get-font-file-ready
1818
"setup font file and get the absolute path to it

0 commit comments

Comments
 (0)