Skip to content

Commit

Permalink
fix: add ulink support for p chat and com request back
Browse files Browse the repository at this point in the history
blocking e2e test

Signed-off-by: yqrashawn <namy.19@gmail.com>
  • Loading branch information
yqrashawn committed Oct 25, 2023
1 parent 125c117 commit 781d291
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 21 deletions.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="status-app" />
<data android:scheme="status-im" />
<data android:scheme="ethereum" />
</intent-filter>
</activity>
Expand Down
1 change: 1 addition & 0 deletions ios/StatusIm/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<key>CFBundleURLSchemes</key>
<array>
<string>status-app</string>
<string>status-im</string>
</array>
</dict>
<dict>
Expand Down
1 change: 1 addition & 0 deletions ios/StatusImPR/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<key>CFBundleURLSchemes</key>
<array>
<string>status-app</string>
<string>status-im</string>
</array>
</dict>
<dict>
Expand Down
53 changes: 32 additions & 21 deletions src/status_im/router/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

(def ethereum-scheme "ethereum:")

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

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

Expand All @@ -30,6 +30,10 @@

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

(def group-chat-extractor
{[#"(.*)" :params] {"" :group-chat
"/" :group-chat}})

(def eip-extractor
{#{[:prefix "-" :address]
[:address]}
Expand All @@ -40,7 +44,12 @@
(def routes
[""
{handled-schemes {["c/" :community-data] :community
["cc/" :chat-data] :community-chat
["cc/" :chat-data] :community-channel
["ccm/" :chat-id] :community-chat
["p/" :chat-id] :private-chat
["cr/" :community-id] :community-requests
"g/" group-chat-extractor
["wallet/" :account] :wallet-account
["u/" :user-data] :user}
ethereum-scheme eip-extractor}])

Expand All @@ -58,7 +67,6 @@

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

(and (or (= handler :community) (= handler :community-chat)) fragment)
(and (or (= handler :community) (= handler :community-channel)) fragment)
(assoc-in [:route-params :community-id] fragment)

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

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

(and equal-end-of-base64url (= handler :user) (:user-data route-params))
Expand Down Expand Up @@ -238,8 +246,8 @@
:community))

(defn handle-uri
[chain _chats uri cb]
(let [{:keys [handler route-params]} (match-uri uri)]
[chain chats uri cb]
(let [{:keys [handler route-params query-params]} (match-uri uri)]
(log/info "[router] uri " uri " matched " handler " with " route-params)
(cond

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

;; ;; NOTE: removed in `match-uri`, might need this in the future
;; (= handler :private-chat)
;; (match-private-chat-async chain route-params cb)
;; NOTE: removed in `match-uri`, might need this in the future
(= handler :private-chat)
(match-private-chat-async chain route-params cb)

;; ;; NOTE: removed in `match-uri`, might need this in the future
;; (= handler :group-chat)
;; (cb (match-group-chat chats query-params))
;; NOTE: removed in `match-uri`, might need this in the future
(= handler :group-chat)
(cb (match-group-chat chats query-params))

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

;; ;; NOTE: removed in `match-uri`, might need this in the future
;; (= handler :community-requests)
;; (cb {:type handler :community-id (:community-id route-params)})
;; NOTE: removed in `match-uri`, might need this in the future
(= handler :community-requests)
(cb {:type handler :community-id (:community-id route-params)})

(and (= handler :community) (:community-id route-params))
(cb {:type (community-route-type route-params)
:community-id (:community-id route-params)})

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

(and (= handler :community-chat) (:community-id route-params))
(= handler :community-chat)
(cb {:type handler :chat-id (:chat-id route-params)})

(and (= handler :community-channel) (:community-id route-params))
(cb {:type (community-route-type route-params)
:community-id (:community-id route-params)})

;; ;; NOTE: removed in `match-uri`, might need this in the future
;; (= handler :wallet-account)
;; (cb (match-wallet-account route-params))
;; NOTE: removed in `match-uri`, might need this in the future
(= handler :wallet-account)
(cb (match-wallet-account route-params))

(address/address? uri)
(cb (address->eip681 uri))
Expand Down

0 comments on commit 781d291

Please sign in to comment.