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 <andrea.maria.piana@gmail.com>
This commit is contained in:
Andrea Maria Piana 2021-03-19 11:54:45 +01:00
parent 8268346dfa
commit a99e7f660f
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
5 changed files with 28 additions and 12 deletions

View File

@ -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]}

View File

@ -120,6 +120,7 @@
"wakuext_inviteUsersToCommunity" {}
"wakuext_shareCommunity" {}
"wakuext_removeUserFromCommunity" {}
"wakuext_banUserFromCommunity" {}
"wakuext_requestToJoinCommunity" {}
"wakuext_acceptRequestToJoinCommunity" {}
"wakuext_declineRequestToJoinCommunity" {}

View File

@ -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 (<sub [:contacts/contact-by-identity public-key])
[first-name second-name] (<sub [:contacts/contact-two-names-by-identity public-key])]
@ -55,7 +57,7 @@
[quo/button {:on-press
#(>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}

View File

@ -2,7 +2,7 @@
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' 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"
}

View File

@ -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",