From 1ebc19a73217fcf2d16f80b9c9a00d9386db121e 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 | 16 +++++++++------- src/status_im/utils/universal_links/utils.cljs | 6 ++++-- src/status_im2/constants.cljs | 2 ++ 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 58dbd759ed2c..e9e16952761b 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -70,6 +70,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..8d8b03267272 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."]) @@ -40,6 +40,8 @@ (def routes ["" {handled-schemes {["c/" :community-data] :community + ["p/" :chat-id] :private-chat + ["cr/" :community-id] :community-requests ["cc/" :chat-data] :community-chat ["u/" :user-data] :user} ethereum-scheme eip-extractor}]) @@ -253,9 +255,9 @@ (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) @@ -264,9 +266,9 @@ (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) diff --git a/src/status_im/utils/universal_links/utils.cljs b/src/status_im/utils/universal_links/utils.cljs index f754389306b5..29bf78b5795b 100644 --- a/src/status_im/utils/universal_links/utils.cljs +++ b/src/status_im/utils/universal_links/utils.cljs @@ -16,12 +16,14 @@ (defn universal-link? [url] (boolean - (re-matches constants/regx-universal-link url))) + (or (re-matches constants/regx-universal-link url) + (re-matches constants/regx-universal-link-deprecated url)))) (defn deep-link? [url] (boolean - (re-matches constants/regx-deep-link url))) + (or (re-matches constants/regx-deep-link url) + (re-matches constants/regx-deep-link-deprecated url)))) (defn generate-link [link-type domain-type param] diff --git a/src/status_im2/constants.cljs b/src/status_im2/constants.cljs index 7f3f57f78b08..9768af82552a 100644 --- a/src/status_im2/constants.cljs +++ b/src/status_im2/constants.cljs @@ -179,8 +179,10 @@ (def regx-italic #"~[^~]+~") (def regx-backquote #"`[^`]+`") (def regx-universal-link #"((^https?://status.app/)|(^status-app://))[\x00-\x7F]+$") +(def regx-universal-link-deprecated #"((^https?://status.app/)|(^status-im://))[\x00-\x7F]+$") (def regx-community-universal-link #"((^https?://status.app/)|(^status-app://))c/([\x00-\x7F]+)$") (def regx-deep-link #"((^ethereum:.*)|(^status-app://[\x00-\x7F]+$))") +(def regx-deep-link-deprecated #"((^ethereum:.*)|(^status-im://[\x00-\x7F]+$))") (def regx-ens #"^(?=.{5,255}$)([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.[a-zA-Z]{2,}$") (def regx-address #"^0x[a-fA-F0-9]{40}$") (def regx-address-contains #"(?i)0x[a-fA-F0-9]{40}")