refactor: always request access to join community

We no longer send community invites to users, instead we just share the
community and let users request access.

That request will either be automatically or manually accepted by the owner/admin.

Depends on https://github.com/status-im/status-go/pull/2682

Closes #5115
This commit is contained in:
Pascal Precht 2022-05-31 13:16:11 +02:00
parent eb7fa5be8b
commit 3dadc7ebbc
No known key found for this signature in database
GPG Key ID: 3017C135E0731E5A
7 changed files with 21 additions and 11 deletions

View File

@ -90,8 +90,10 @@ QtObject:
self.observedItem.setActiveSectionData(item)
self.observedItemChanged()
proc joinCommunity*(self: View, communityId: string): string {.slot.} =
result = self.delegate.joinCommunity(communityId)
proc joinCommunity*(self: View, communityId: string, ensName: string) {.slot.} =
# Users always have to request to join a community but might
# get automatically accepted.
self.delegate.requestToJoinCommunity(communityId, ensName)
proc createCommunity*(self: View, name: string,
description: string, introMessage: string, outroMessage: string,

View File

@ -1066,11 +1066,13 @@ QtObject:
var pubKeys: seq[string] = @[]
for pubKey in pubKeysParsed:
pubKeys.add(pubKey.getStr)
let response = status_go.inviteUsersToCommunity(communityId, pubKeys)
# We no longer send invites, but merely share the community so
# users can request access (with automatic acception)
let response = status_go.shareCommunityToUsers(communityId, pubKeys)
discard self.chatService.processMessageUpdateAfterSend(response)
except Exception as e:
error "Error inviting to community", msg = e.msg
result = "Error exporting community: " & e.msg
error "Error sharing community", msg = e.msg
result = "Error sharing community: " & e.msg
proc removeUserFromCommunity*(self: Service, communityId: string, pubKey: string) =
try:

View File

@ -260,5 +260,11 @@ proc inviteUsersToCommunity*(communityId: string, pubKeys: seq[string]): RpcResp
"users": pubKeys
}])
proc shareCommunityToUsers*(communityId: string, pubKeys: seq[string]): RpcResponse[JsonNode] {.raises: [Exception].} =
return callPrivateRPC("shareCommunity".prefix, %*[{
"communityId": communityId,
"users": pubKeys
}])
proc getCommunitiesSettings*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return callPrivateRPC("getCommunitiesSettings".prefix, %*[])

View File

@ -216,7 +216,7 @@ StatusModal {
// text = qsTrId("invite-chat-pending")
// }
} else {
error = root.store.communitiesModuleInst.joinCommunity(root.communityId)
error = root.store.communitiesModuleInst.joinCommunity(root.communityId, root.store.userProfileInst.ensName)
}
if (error) {

View File

@ -341,8 +341,8 @@ QtObject {
chatCommunitySectionModule.reorderCommunityChat(categoryId, chatId, to)
}
function joinCommunity(id) {
return communitiesModuleInst.joinCommunity(id)
function joinCommunity(id, ensName) {
return communitiesModuleInst.joinCommunity(id, ensName)
}
function requestToJoinCommunity(id, ensName) {
@ -425,7 +425,7 @@ QtObject {
const userCanJoin = userCanJoin(communityId)
// TODO find what to do when you can't join
if (userCanJoin) {
joinCommunity(communityId, true)
joinCommunity(communityId, userProfileInst.ensName)
}
}
return result

View File

@ -275,7 +275,7 @@ Item {
}
if (rectangleBubble.state === "unjoined") {
Global.openPopup(communityIntroDialog, { joinMethod: () => {
let error = root.store.joinCommunity(communityId)
let error = root.store.joinCommunity(communityId, userProfile.name)
if (error) joiningError.showError(error)
} });
}

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 23d745fe0a61501b847af9c54479d5fa763a51d0
Subproject commit 8ccb3ece6ffb433b5c313a4a89efeafce8e82d3c