From a99e7f660f9ab1d070e6644be497b796a9fa1c25 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Fri, 19 Mar 2021 11:54:45 +0100 Subject: [PATCH] Add banning of users in communities This commit adds bannning of users in communities for on-request and invitation only communities. Signed-off-by: Andrea Maria Piana --- src/status_im/communities/core.cljs | 14 +++++++++++++- src/status_im/ethereum/json_rpc.cljs | 1 + .../ui/screens/communities/members.cljs | 18 ++++++++++-------- status-go-version.json | 6 +++--- translations/en.json | 1 + 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/status_im/communities/core.cljs b/src/status_im/communities/core.cljs index c77ad06290..8dbb174c12 100644 --- a/src/status_im/communities/core.cljs +++ b/src/status_im/communities/core.cljs @@ -350,10 +350,22 @@ [{:keys [db]} field value] {:db (assoc-in db [:communities/create field] value)}) +(fx/defn member-banned + {:events [::member-banned]} + [cofx response-js] + (fx/merge cofx + (bottom-sheet/hide-bottom-sheet) + (handle-response response-js))) + (fx/defn member-ban {:events [::member-ban]} [cofx community-id public-key] - (log/error "Community member ban is not yet implemented")) + {::json-rpc/call [{:method "wakuext_banUserFromCommunity" + :params [{:communityId community-id + :user public-key}] + :js-response true + :on-success #(re-frame/dispatch [::member-banned %]) + :on-error #(log/error "failed to ban user from community" community-id public-key %)}]}) (fx/defn member-kicked {:events [::member-kicked]} diff --git a/src/status_im/ethereum/json_rpc.cljs b/src/status_im/ethereum/json_rpc.cljs index e18fb77d52..2b04db899e 100644 --- a/src/status_im/ethereum/json_rpc.cljs +++ b/src/status_im/ethereum/json_rpc.cljs @@ -120,6 +120,7 @@ "wakuext_inviteUsersToCommunity" {} "wakuext_shareCommunity" {} "wakuext_removeUserFromCommunity" {} + "wakuext_banUserFromCommunity" {} "wakuext_requestToJoinCommunity" {} "wakuext_acceptRequestToJoinCommunity" {} "wakuext_declineRequestToJoinCommunity" {} diff --git a/src/status_im/ui/screens/communities/members.cljs b/src/status_im/ui/screens/communities/members.cljs index b5017685b0..4e14c335c5 100644 --- a/src/status_im/ui/screens/communities/members.cljs +++ b/src/status_im/ui/screens/communities/members.cljs @@ -16,7 +16,7 @@ (>evt [:bottom-sheet/hide]) (>evt event)) -(defn member-sheet [first-name {:keys [public-key] :as member} community-id can-kick-users?] +(defn member-sheet [first-name {:keys [public-key] :as member} community-id can-kick-users? can-manage-users?] [:<> [quo/list-item {:theme :accent @@ -33,15 +33,17 @@ [quo/list-item {:theme :negative :icon :main-icons/arrow-left :title (i18n/label :t/member-kick) - :on-press #(>evt [::communities/member-kick community-id public-key])}] - ; ban not implemented - #_[quo/list-item {:theme :negative - :icon :main-icons/cancel - :title (i18n/label :t/member-ban) - :on-press #(>evt [::communities/member-ban community-id public-key])}]])]) + :on-press #(>evt [::communities/member-kick community-id public-key])}]]) + (when can-manage-users? + [:<> + [quo/list-item {:theme :negative + :icon :main-icons/cancel + :title (i18n/label :t/member-ban) + :on-press #(>evt [::communities/member-ban community-id public-key])}]])]) (defn render-member [public-key _ _ {:keys [community-id my-public-key + can-manage-users? can-kick-users?]}] (let [member (evt [:bottom-sheet/show-sheet {:content (fn [] - [member-sheet first-name member community-id can-kick-users?])}]) + [member-sheet first-name member community-id can-kick-users? can-manage-users?])}]) :type :icon :theme :icon :accessibility-label :menu-option} diff --git a/status-go-version.json b/status-go-version.json index 6af4b92021..69093dd5d9 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -2,7 +2,7 @@ "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh ' instead", "owner": "status-im", "repo": "status-go", - "version": "v0.73.8", - "commit-sha1": "6bea21c197431c381a2ac6641a21befc12b2131c", - "src-sha256": "025cv1376v9pdjkfp4qsm0jlcdfz47r9b3yixg2iyhdwmlc5kjka" + "version": "v0.73.9", + "commit-sha1": "d22182ea8273db6b68b63abc16cf43d1da835f81", + "src-sha256": "1wsz4d11vfvrz9ys1jx9ygynxjdxz1xvavhhgmwkzy8asvhm3gas" } diff --git a/translations/en.json b/translations/en.json index bdcd31a694..403fb305f7 100644 --- a/translations/en.json +++ b/translations/en.json @@ -153,6 +153,7 @@ "members-label": "Members", "open-membership": "Open membership", "member-kick": "Kick member", + "member-ban": "Ban member", "membership-requests": "Membership requests", "community-members-title": "Members", "community-requests-to-join-title": "Membership requests",