From 781d2914a1cca7ee829474aed6ffeea65a819c13 Mon Sep 17 00:00:00 2001 From: yqrashawn Date: Mon, 23 Oct 2023 21:14:08 +0800 Subject: [PATCH] fix: add ulink support for p chat and com request back blocking e2e test Signed-off-by: yqrashawn --- android/app/src/main/AndroidManifest.xml | 1 + ios/StatusIm/Info.plist | 1 + ios/StatusImPR/Info.plist | 1 + src/status_im/router/core.cljs | 53 ++++++++++++++---------- 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 5efe8eb2f185..ef1f2df51792 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -71,6 +71,7 @@ + diff --git a/ios/StatusIm/Info.plist b/ios/StatusIm/Info.plist index ad0ac043769d..ce96da029cdc 100644 --- a/ios/StatusIm/Info.plist +++ b/ios/StatusIm/Info.plist @@ -34,6 +34,7 @@ CFBundleURLSchemes status-app + status-im diff --git a/ios/StatusImPR/Info.plist b/ios/StatusImPR/Info.plist index 1e0693833c0f..1403685f7866 100644 --- a/ios/StatusImPR/Info.plist +++ b/ios/StatusImPR/Info.plist @@ -30,6 +30,7 @@ CFBundleURLSchemes status-app + status-im diff --git a/src/status_im/router/core.cljs b/src/status_im/router/core.cljs index ab55ac3986c9..511df0e7442d 100644 --- a/src/status_im/router/core.cljs +++ b/src/status_im/router/core.cljs @@ -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."]) @@ -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]} @@ -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}]) @@ -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 @@ -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)) @@ -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 @@ -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))