Skip to content

Commit

Permalink
feat: support /cc/encoded-data and /cc/community-channel-id
Browse files Browse the repository at this point in the history
  • Loading branch information
yqrashawn committed Oct 26, 2023
1 parent 7e5d9aa commit 03c6354
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 13 deletions.
34 changes: 23 additions & 11 deletions src/status_im/router/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@

(def routes
[""
{handled-schemes {["c/" :community-data] :community
["cc/" :community-channel-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
"c" :community
"u" :user}
{handled-schemes {["c/" :community-data] :community
["cc/" :community-data] :community-chat
["p/" :chat-id] :private-chat
["cr/" :community-id] :community-requests
"g/" group-chat-extractor
["wallet/" :account] :wallet-account
["u/" :user-data] :user
"c" :community
"u" :user}
ethereum-scheme eip-extractor}])

(defn parse-query-params
Expand Down Expand Up @@ -96,9 +96,17 @@
(and equal-end-of-base64url (= handler :community) (:community-data route-params))
(update-in [:route-params :community-data] #(str % equal-end-of-base64url))

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

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

(and fragment (= handler :community-chat) (:community-data route-params)
(string? (:community-data route-params))
(string/includes? (:community-data route-params) "-"))
(assoc-in [:route-params :community-channel-id] (:community-data route-params))

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

Expand Down Expand Up @@ -290,9 +298,13 @@
(cb {:type (community-route-type route-params)
:community-id (:community-id route-params)})

(= handler :community-chat)
(and (= handler :community-chat) (:community-channel-id route-params) (:community-id route-params))
(match-community-channel-async route-params cb)

(and (= handler :community-chat) (: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))
Expand Down
20 changes: 18 additions & 2 deletions src/status_im/router/core_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,32 @@

"https://status.app/cc/G54AAKwObLdpiGjXnckYzRcOSq0QQAS_CURGfqVU42ceGHCObstUIknTTZDOKF3E8y2MSicncpO7fTskXnoACiPKeejvjtLTGWNxUhlT7fyQS7Jrr33UVHluxv_PLjV2ePGw5GQ33innzeK34pInIgUGs5RjdQifMVmURalxxQKwiuoY5zwIjixWWRHqjHM=#zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11"
[:community-chat
{:chat-data
{:community-data
"G54AAKwObLdpiGjXnckYzRcOSq0QQAS_CURGfqVU42ceGHCObstUIknTTZDOKF3E8y2MSicncpO7fTskXnoACiPKeejvjtLTGWNxUhlT7fyQS7Jrr33UVHluxv_PLjV2ePGw5GQ33innzeK34pInIgUGs5RjdQifMVmURalxxQKwiuoY5zwIjixWWRHqjHM="
:community-id "zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11"}]

"status-app://cc/G54AAKwObLdpiGjXnckYzRcOSq0QQAS_CURGfqVU42ceGHCObstUIknTTZDOKF3E8y2MSicncpO7fTskXnoACiPKeejvjtLTGWNxUhlT7fyQS7Jrr33UVHluxv_PLjV2ePGw5GQ33innzeK34pInIgUGs5RjdQifMVmURalxxQKwiuoY5zwIjixWWRHqjHM=#zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11"
[:community-chat
{:chat-data
{:community-data
"G54AAKwObLdpiGjXnckYzRcOSq0QQAS_CURGfqVU42ceGHCObstUIknTTZDOKF3E8y2MSicncpO7fTskXnoACiPKeejvjtLTGWNxUhlT7fyQS7Jrr33UVHluxv_PLjV2ePGw5GQ33innzeK34pInIgUGs5RjdQifMVmURalxxQKwiuoY5zwIjixWWRHqjHM="
:community-id "zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11"}]

"https://status.app/cc/c432709e-fc73-440d-bb67-cb3a0929dfda#zQ3shZL6dXiFCbDyxnXxwQa9v8QFC2q19subFtyxd7kVszMVo"
[:community-chat
{:community-data
"c432709e-fc73-440d-bb67-cb3a0929dfda"
:community-channel-id
"c432709e-fc73-440d-bb67-cb3a0929dfda"
:community-id "zQ3shZL6dXiFCbDyxnXxwQa9v8QFC2q19subFtyxd7kVszMVo"}]

"status-app://cc/c432709e-fc73-440d-bb67-cb3a0929dfda#zQ3shZL6dXiFCbDyxnXxwQa9v8QFC2q19subFtyxd7kVszMVo"
[:community-chat
{:community-data
"c432709e-fc73-440d-bb67-cb3a0929dfda"
:community-channel-id
"c432709e-fc73-440d-bb67-cb3a0929dfda"
:community-id "zQ3shZL6dXiFCbDyxnXxwQa9v8QFC2q19subFtyxd7kVszMVo"}]

"https://status.app/c/iyKACkQKB0Rvb2RsZXMSJ0NvbG9yaW5nIHRoZSB3b3JsZCB3aXRoIGpveSDigKIg4bSXIOKAohiYohsiByMxMzFEMkYqAwEhMwM=#zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11"
[:community
{:community-data
Expand Down

0 comments on commit 03c6354

Please sign in to comment.