Skip to content

Commit f66e236

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 125c117 commit f66e236

File tree

1 file changed

+31
-20
lines changed

1 file changed

+31
-20
lines changed

src/status_im/router/core.cljs

+31-20
Original file line numberDiff line numberDiff line change
@@ -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))

0 commit comments

Comments
 (0)