Skip to content

Commit dc9f77d

Browse files
committed
fix: add ulink support for p chat and com request back
blocking e2e test Signed-off-by: yqrashawn <[email protected]>
1 parent 8296bda commit dc9f77d

File tree

6 files changed

+41
-23
lines changed

6 files changed

+41
-23
lines changed

android/app/src/main/AndroidManifest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
<category android:name="android.intent.category.DEFAULT" />
7272
<category android:name="android.intent.category.BROWSABLE" />
7373
<data android:scheme="status-app" />
74+
<data android:scheme="status-im" />
7475
<data android:scheme="ethereum" />
7576
</intent-filter>
7677
</activity>

ios/StatusIm/Info.plist

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<key>CFBundleURLSchemes</key>
3535
<array>
3636
<string>status-app</string>
37+
<string>status-im</string>
3738
</array>
3839
</dict>
3940
<dict>

ios/StatusImPR/Info.plist

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<key>CFBundleURLSchemes</key>
3131
<array>
3232
<string>status-app</string>
33+
<string>status-im</string>
3334
</array>
3435
</dict>
3536
<dict>

src/status_im/router/core.cljs

+32-21
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
(def ethereum-scheme "ethereum:")
2222

23-
(def uri-schemes ["status-app://"])
23+
(def uri-schemes ["status-app://" "status-im://" "status-im:"])
2424

2525
(def web-prefixes ["https://" "http://" "https://www." "http://www."])
2626

@@ -30,6 +30,10 @@
3030

3131
(def handled-schemes (set (into uri-schemes web-urls)))
3232

33+
(def group-chat-extractor
34+
{[#"(.*)" :params] {"" :group-chat
35+
"/" :group-chat}})
36+
3337
(def eip-extractor
3438
{#{[:prefix "-" :address]
3539
[:address]}
@@ -40,7 +44,12 @@
4044
(def routes
4145
[""
4246
{handled-schemes {["c/" :community-data] :community
43-
["cc/" :chat-data] :community-chat
47+
["cc/" :chat-data] :community-channel
48+
["ccm/" :chat-id] :community-chat
49+
["p/" :chat-id] :private-chat
50+
["cr/" :community-id] :community-requests
51+
"g/" group-chat-extractor
52+
["wallet/" :account] :wallet-account
4453
["u/" :user-data] :user}
4554
ethereum-scheme eip-extractor}])
4655

@@ -58,7 +67,6 @@
5867

5968
(defn match-uri
6069
[uri]
61-
;;
6270
(let [;; bidi has trouble parse path with `=` in it extract `=` here and add back to parsed
6371
;; base64url regex based on https://datatracker.ietf.org/doc/html/rfc4648#section-5 may
6472
;; include invalid base64 (invalid length, length of any base64 encoded string must be a
@@ -81,13 +89,13 @@
8189
ens?
8290
(assoc-in [:route-params :ens-name] fragment)
8391

84-
(and (or (= handler :community) (= handler :community-chat)) fragment)
92+
(and (or (= handler :community) (= handler :community-channel)) fragment)
8593
(assoc-in [:route-params :community-id] fragment)
8694

8795
(and equal-end-of-base64url (= handler :community) (:community-data route-params))
8896
(update-in [:route-params :community-data] #(str % equal-end-of-base64url))
8997

90-
(and equal-end-of-base64url (= handler :community-chat) (:chat-data route-params))
98+
(and equal-end-of-base64url (= handler :community-channel) (:chat-data route-params))
9199
(update-in [:route-params :chat-data] #(str % equal-end-of-base64url))
92100

93101
(and equal-end-of-base64url (= handler :user) (:user-data route-params))
@@ -238,8 +246,8 @@
238246
:community))
239247

240248
(defn handle-uri
241-
[chain _chats uri cb]
242-
(let [{:keys [handler route-params]} (match-uri uri)]
249+
[chain chats uri cb]
250+
(let [{:keys [handler route-params query-params]} (match-uri uri)]
243251
(log/info "[router] uri " uri " matched " handler " with " route-params)
244252
(cond
245253

@@ -253,36 +261,39 @@
253261
(and (= handler :user) (:user-id route-params))
254262
(match-contact-async chain route-params cb)
255263

256-
;; ;; NOTE: removed in `match-uri`, might need this in the future
257-
;; (= handler :private-chat)
258-
;; (match-private-chat-async chain route-params cb)
264+
;; NOTE: removed in `match-uri`, might need this in the future
265+
(= handler :private-chat)
266+
(match-private-chat-async chain route-params cb)
259267

260-
;; ;; NOTE: removed in `match-uri`, might need this in the future
261-
;; (= handler :group-chat)
262-
;; (cb (match-group-chat chats query-params))
268+
;; NOTE: removed in `match-uri`, might need this in the future
269+
(= handler :group-chat)
270+
(cb (match-group-chat chats query-params))
263271

264272
(validators/valid-public-key? uri)
265273
(match-contact-async chain {:user-id uri} cb)
266274

267-
;; ;; NOTE: removed in `match-uri`, might need this in the future
268-
;; (= handler :community-requests)
269-
;; (cb {:type handler :community-id (:community-id route-params)})
275+
;; NOTE: removed in `match-uri`, might need this in the future
276+
(= handler :community-requests)
277+
(cb {:type handler :community-id (:community-id route-params)})
270278

271279
(and (= handler :community) (:community-id route-params))
272280
(cb {:type (community-route-type route-params)
273281
:community-id (:community-id route-params)})
274282

275283
;; ;; TODO: jump to community overview for now, should jump to community channel
276-
;; (and (= handler :community-chat) (:chat-id route-params))
284+
;; (and (= handler :community-channel) (:chat-id route-params))
277285
;; (cb {:type handler :chat-id (:chat-id route-params)})
278286

279-
(and (= handler :community-chat) (:community-id route-params))
287+
(= handler :community-chat)
288+
(cb {:type handler :chat-id (:chat-id route-params)})
289+
290+
(and (= handler :community-channel) (:community-id route-params))
280291
(cb {:type (community-route-type route-params)
281292
:community-id (:community-id route-params)})
282293

283-
;; ;; NOTE: removed in `match-uri`, might need this in the future
284-
;; (= handler :wallet-account)
285-
;; (cb (match-wallet-account route-params))
294+
;; NOTE: removed in `match-uri`, might need this in the future
295+
(= handler :wallet-account)
296+
(cb (match-wallet-account route-params))
286297

287298
(address/address? uri)
288299
(cb (address->eip681 uri))

src/status_im/utils/universal_links/utils.cljs

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
(defn universal-link?
1717
[url]
1818
(boolean
19-
(re-matches constants/regx-universal-link url)))
19+
(or (re-matches constants/regx-universal-link url)
20+
(re-matches constants/regx-universal-link-deprecated url))))
2021

2122
(defn deep-link?
2223
[url]
2324
(boolean
24-
(re-matches constants/regx-deep-link url)))
25+
(or (re-matches constants/regx-deep-link url)
26+
(re-matches constants/regx-deep-link-deprecated url))))
2527

2628
(defn generate-link
2729
[link-type domain-type param]

src/status_im2/constants.cljs

+2
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,10 @@
179179
(def regx-italic #"~[^~]+~")
180180
(def regx-backquote #"`[^`]+`")
181181
(def regx-universal-link #"((^https?://status.app/)|(^status-app://))[\x00-\x7F]+$")
182+
(def regx-universal-link-deprecated #"((^https?://status.app/)|(^status-im://))[\x00-\x7F]+$")
182183
(def regx-community-universal-link #"((^https?://status.app/)|(^status-app://))c/([\x00-\x7F]+)$")
183184
(def regx-deep-link #"((^ethereum:.*)|(^status-app://[\x00-\x7F]+$))")
185+
(def regx-deep-link-deprecated #"((^ethereum:.*)|(^status-im://[\x00-\x7F]+$))")
184186
(def regx-ens #"^(?=.{5,255}$)([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.[a-zA-Z]{2,}$")
185187
(def regx-address #"^0x[a-fA-F0-9]{40}$")
186188
(def regx-address-contains #"(?i)0x[a-fA-F0-9]{40}")

0 commit comments

Comments
 (0)