feat(Communities): allow admins to ban users

Closes #2514
This commit is contained in:
Pascal Precht 2021-05-17 15:04:56 +02:00 committed by Iuri Matias
parent 0b4c465f51
commit 2a706d2b09
4 changed files with 23 additions and 11 deletions

View File

@ -318,6 +318,8 @@ QtObject:
except Exception as e:
error "Error removing user from the community", msg = e.msg
proc banUserFromCommunity*(self: CommunitiesView, pubKey: string, communityId: string) {.slot.} =
discard self.status.chat.banUserFromCommunity(pubKey, communityId)
proc requestToJoinCommunity*(self: CommunitiesView, communityId: string, ensName: string) {.slot.} =
try:

View File

@ -491,6 +491,9 @@ proc inviteUsersToCommunity*(self: ChatModel, communityId: string, pubKeys: seq[
proc removeUserFromCommunity*(self: ChatModel, communityId: string, pubKey: string) =
status_chat.removeUserFromCommunity(communityId, pubKey)
proc banUserFromCommunity*(self: ChatModel, pubKey: string, communityId: string): string =
return status_chat.banUserFromCommunity(pubKey, communityId)
proc exportCommunity*(self: ChatModel, communityId: string): string =
result = status_chat.exportCommunity(communityId)
@ -510,4 +513,4 @@ proc pendingRequestsToJoinForCommunity*(self: ChatModel, communityKey: string):
result = status_chat.pendingRequestsToJoinForCommunity(communityKey)
proc myPendingRequestsToJoin*(self: ChatModel): seq[CommunityMembershipRequest] =
result = status_chat.myPendingRequestsToJoin()
result = status_chat.myPendingRequestsToJoin()

View File

@ -381,4 +381,10 @@ proc myPendingRequestsToJoin*(): seq[CommunityMembershipRequest] =
for jsonCommunityReqest in rpcResult["result"]:
communityRequests.add(jsonCommunityReqest.toCommunityMembershipRequest())
return communityRequests
return communityRequests
proc banUserFromCommunity*(pubKey: string, communityId: string): string =
return callPrivateRPC("banUserFromCommunity".prefix, %*[{
"communityId": communityId,
"user": pubKey
}])

View File

@ -163,15 +163,16 @@ Item {
text: qsTrId("kick")
onTriggered: chatsModel.communities.removeUserFromCommunity(model.pubKey)
}
/* Action { */
/* icon.source: "../../../img/communities/menu/ban.svg" */
/* icon.width: 16 */
/* icon.height: 16 */
/* icon.color: Style.current.red */
/* //% "Ban" */
/* text: qsTrId("ban") */
/* onTriggered: console.log("TODO") */
/* } */
Action {
property string type: "danger"
icon.source: "../../../img/communities/menu/ban.svg"
icon.width: 16
icon.height: 16
icon.color: Style.current.red
//% "Ban"
text: qsTrId("ban")
onTriggered: chatsModel.communities.banUserFromCommunity(model.pubKey, chatsModel.communities.activeCommunity.id)
}
/* Separator {} */
/* Action { */
/* icon.source: "../../../img/communities/menu/transfer-ownership.svg" */