refactor(communities): rename inviteUsersToCommunity to shareCommunityToUsers

This change corrects legacy naming that was causing confusion.

Community invites are no longer sent to users. Instead, the community is
just shared. If a user is interested in joining this shared commmunity,
they must submit a request to join.
This commit is contained in:
Patryk Osmaczko 2023-07-26 11:42:30 +02:00 committed by osmaczko
parent dea0e99bbb
commit faa425dd29
12 changed files with 77 additions and 83 deletions

View File

@ -679,8 +679,8 @@ proc unmuteCategory*(self: Controller, categoryId: string) =
proc setCommunityMuted*(self: Controller, mutedType: int) =
self.communityService.setCommunityMuted(self.sectionId, mutedType)
proc inviteUsersToCommunity*(self: Controller, pubKeys: string, inviteMessage: string): string =
result = self.communityService.inviteUsersToCommunityById(self.sectionId, pubKeys, inviteMessage)
proc shareCommunityToUsers*(self: Controller, pubKeys: string, inviteMessage: string): string =
result = self.communityService.shareCommunityToUsers(self.sectionId, pubKeys, inviteMessage)
proc reorderCommunityCategories*(self: Controller, categoryId: string, position: int) =
self.communityService.reorderCommunityCategories(self.sectionId, categoryId, position)

View File

@ -307,7 +307,7 @@ method exportCommunity*(self: AccessInterface): string {.base.} =
method setCommunityMuted*(self: AccessInterface, mutedType: int) {.base.} =
raise newException(ValueError, "No implementation available")
method inviteUsersToCommunity*(self: AccessInterface, pubKeysJSON: string, inviteMessage: string): string {.base.} =
method shareCommunityToUsers*(self: AccessInterface, pubKeysJSON: string, inviteMessage: string): string {.base.} =
raise newException(ValueError, "No implementation available")
method createCommunityCategory*(self: AccessInterface, name: string, channels: seq[string]) {.base.} =

View File

@ -1119,8 +1119,8 @@ method exportCommunity*(self: Module): string =
method setCommunityMuted*(self: Module, mutedType: int) =
self.controller.setCommunityMuted(mutedType)
method inviteUsersToCommunity*(self: Module, pubKeysJSON: string, inviteMessage: string): string =
result = self.controller.inviteUsersToCommunity(pubKeysJSON, inviteMessage)
method shareCommunityToUsers*(self: Module, pubKeysJSON: string, inviteMessage: string): string =
result = self.controller.shareCommunityToUsers(pubKeysJSON, inviteMessage)
method prepareEditCategoryModel*(self: Module, categoryId: string) =
self.view.editCategoryChannelsModel().clearItems()

View File

@ -325,8 +325,8 @@ QtObject:
proc setCommunityMuted*(self: View, mutedType: int) {.slot.} =
self.delegate.setCommunityMuted(mutedType)
proc inviteUsersToCommunity*(self: View, pubKeysJSON: string, inviteMessage: string): string {.slot.} =
result = self.delegate.inviteUsersToCommunity(pubKeysJSON, inviteMessage)
proc shareCommunityToUsers*(self: View, pubKeysJSON: string, inviteMessage: string): string {.slot.} =
result = self.delegate.shareCommunityToUsers(pubKeysJSON, inviteMessage)
proc createCommunityCategory*(self: View, name: string, channels: string) {.slot.} =
let channelsSeq = map(parseJson(channels).getElems(), proc(x:JsonNode):string = x.getStr())

View File

@ -17,8 +17,8 @@ proc newController*(delegate: io_interface.AccessInterface,
proc delete*(self: Controller) =
discard
proc inviteUsersToCommunity*(self: Controller, communityID: string, pubKeys: string, inviteMessage: string): string =
result = self.communityService.inviteUsersToCommunityById(communityID, pubKeys, inviteMessage)
proc shareCommunityToUsers*(self: Controller, communityID: string, pubKeys: string, inviteMessage: string): string =
result = self.communityService.shareCommunityToUsers(communityID, pubKeys, inviteMessage)
proc leaveCommunity*(self: Controller, communityID: string) =
self.communityService.leaveCommunity(communityID)

View File

@ -22,7 +22,7 @@ method getModuleAsVariant*(self: AccessInterface): QVariant {.base.} =
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method inviteUsersToCommunity*(self: AccessInterface, communityID: string, pubKeysJSON: string, inviteMessage: string): string {.base.} =
method shareCommunityToUsers*(self: AccessInterface, communityID: string, pubKeysJSON: string, inviteMessage: string): string {.base.} =
raise newException(ValueError, "No implementation available")
method leaveCommunity*(self: AccessInterface, communityID: string) {.base.} =

View File

@ -42,8 +42,8 @@ method viewDidLoad*(self: Module) =
method getModuleAsVariant*(self: Module): QVariant =
return self.viewVariant
method inviteUsersToCommunity*(self: Module, communityID: string, pubKeysJSON: string, inviteMessage: string): string =
result = self.controller.inviteUsersToCommunity(communityID, pubKeysJSON, inviteMessage)
method shareCommunityToUsers*(self: Module, communityID: string, pubKeysJSON: string, inviteMessage: string): string =
result = self.controller.shareCommunityToUsers(communityID, pubKeysJSON, inviteMessage)
method leaveCommunity*(self: Module, communityID: string) =
self.controller.leaveCommunity(communityID)

View File

@ -19,8 +19,8 @@ QtObject:
proc load*(self: View) =
self.delegate.viewDidLoad()
method inviteUsersToCommunity*(self: View, communityID: string, pubKeysJSON: string, inviteMessage: string): string {.slot.} =
result = self.delegate.inviteUsersToCommunity(communityID, pubKeysJSON, inviteMessage)
method shareCommunityToUsers*(self: View, communityID: string, pubKeysJSON: string, inviteMessage: string): string {.slot.} =
result = self.delegate.shareCommunityToUsers(communityID, pubKeysJSON, inviteMessage)
method leaveCommunity*(self: View, communityID: string) {.slot.} =
self.delegate.leaveCommunity(communityID)

View File

@ -1745,7 +1745,7 @@ QtObject:
except Exception as e:
error "Error declining request to join community", msg = e.msg
proc inviteUsersToCommunityById*(self: Service, communityId: string, pubKeysJson: string, inviteMessage: string): string =
proc shareCommunityToUsers*(self: Service, communityId: string, pubKeysJson: string, inviteMessage: string): string =
try:
let pubKeysParsed = pubKeysJson.parseJson
var pubKeys: seq[string] = @[]

View File

@ -401,12 +401,6 @@ proc setCommunityMuted*(communityId: string, mutedType: int): RpcResponse[JsonNo
"mutedType": mutedType
}])
proc inviteUsersToCommunity*(communityId: string, pubKeys: seq[string]): RpcResponse[JsonNode] {.raises: [Exception].} =
return callPrivateRPC("inviteUsersToCommunity".prefix, %*[{
"communityId": communityId,
"users": pubKeys
}])
proc shareCommunityToUsers*(communityId: string, pubKeys: seq[string], inviteMessage: string): RpcResponse[JsonNode] {.raises: [Exception].} =
return callPrivateRPC("shareCommunity".prefix, %*[{
"communityId": communityId,

View File

@ -94,8 +94,8 @@ SplitView {
}
communitySectionModule: QtObject {
function inviteUsersToCommunity(keys, message) {
logs.logEvent("communitySectionModule::inviteUsersToCommunity",
function shareCommunityToUsers(keys, message) {
logs.logEvent("communitySectionModule::shareCommunityToUsers",
["keys", "message"], arguments)
}
}

View File

@ -30,8 +30,8 @@ StatusStackModal {
readonly property int footerButtonsHeight: 44
readonly property int popupContentHeight: 551
function sendInvites(pubKeys, inviteMessage) {
const error = root.communitySectionModule.inviteUsersToCommunity(JSON.stringify(pubKeys), inviteMessage);
function shareCommunity(pubKeys, inviteMessage) {
const error = root.communitySectionModule.shareCommunityToUsers(JSON.stringify(pubKeys), inviteMessage);
d.processInviteResult(error);
}
@ -75,7 +75,7 @@ StatusStackModal {
enabled: root.pubKeys.length > 0
text: qsTr("Send %n invite(s)", "", root.pubKeys.length)
onClicked: {
d.sendInvites(root.pubKeys, root.inviteMessage);
d.shareCommunity(root.pubKeys, root.inviteMessage);
root.close();
}
}