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

@ -52,7 +52,7 @@ type
tmpAuthenticationWithCallbackInProgress: bool tmpAuthenticationWithCallbackInProgress: bool
proc newController*(delegate: io_interface.AccessInterface, sectionId: string, isCommunity: bool, events: EventEmitter, proc newController*(delegate: io_interface.AccessInterface, sectionId: string, isCommunity: bool, events: EventEmitter,
settingsService: settings_service.Service, nodeConfigurationService: node_configuration_service.Service, settingsService: settings_service.Service, nodeConfigurationService: node_configuration_service.Service,
contactService: contact_service.Service, chatService: chat_service.Service, communityService: community_service.Service, contactService: contact_service.Service, chatService: chat_service.Service, communityService: community_service.Service,
messageService: message_service.Service, gifService: gif_service.Service, messageService: message_service.Service, gifService: gif_service.Service,
mailserversService: mailservers_service.Service, mailserversService: mailservers_service.Service,
@ -84,7 +84,7 @@ proc newController*(delegate: io_interface.AccessInterface, sectionId: string, i
result.tmpAirdropAddress = "" result.tmpAirdropAddress = ""
result.tmpAddressesToShare = @[] result.tmpAddressesToShare = @[]
result.tmpAuthenticationWithCallbackInProgress = true result.tmpAuthenticationWithCallbackInProgress = true
proc delete*(self: Controller) = proc delete*(self: Controller) =
self.events.disconnect() self.events.disconnect()
@ -301,12 +301,12 @@ proc init*(self: Controller) =
let args = ReloadMessagesArgs(e) let args = ReloadMessagesArgs(e)
if (args.communityId == self.sectionId): if (args.communityId == self.sectionId):
self.messageService.asyncLoadInitialMessagesForChat(self.getActiveChatId()) self.messageService.asyncLoadInitialMessagesForChat(self.getActiveChatId())
self.events.on(SIGNAL_CATEGORY_MUTED) do(e: Args): self.events.on(SIGNAL_CATEGORY_MUTED) do(e: Args):
let args = CategoryArgs(e) let args = CategoryArgs(e)
if (args.communityId == self.sectionId): if (args.communityId == self.sectionId):
self.delegate.onCategoryMuted(args.categoryId) self.delegate.onCategoryMuted(args.categoryId)
self.events.on(SIGNAL_CATEGORY_UNMUTED) do(e: Args): self.events.on(SIGNAL_CATEGORY_UNMUTED) do(e: Args):
let args = CategoryArgs(e) let args = CategoryArgs(e)
if (args.communityId == self.sectionId): if (args.communityId == self.sectionId):
@ -414,7 +414,7 @@ proc init*(self: Controller) =
if (self.sectionId != args.sectionId): if (self.sectionId != args.sectionId):
return return
self.delegate.makeChatWithIdActive(args.chatId) self.delegate.makeChatWithIdActive(args.chatId)
if (not self.isCommunitySection): if (not self.isCommunitySection):
self.events.on(SIGNAL_CHAT_SWITCH_TO_OR_CREATE_1_1_CHAT) do(e:Args): self.events.on(SIGNAL_CHAT_SWITCH_TO_OR_CREATE_1_1_CHAT) do(e:Args):
let args = ChatExtArgs(e) let args = ChatExtArgs(e)
@ -679,8 +679,8 @@ proc unmuteCategory*(self: Controller, categoryId: string) =
proc setCommunityMuted*(self: Controller, mutedType: int) = proc setCommunityMuted*(self: Controller, mutedType: int) =
self.communityService.setCommunityMuted(self.sectionId, mutedType) self.communityService.setCommunityMuted(self.sectionId, mutedType)
proc inviteUsersToCommunity*(self: Controller, pubKeys: string, inviteMessage: string): string = proc shareCommunityToUsers*(self: Controller, pubKeys: string, inviteMessage: string): string =
result = self.communityService.inviteUsersToCommunityById(self.sectionId, pubKeys, inviteMessage) result = self.communityService.shareCommunityToUsers(self.sectionId, pubKeys, inviteMessage)
proc reorderCommunityCategories*(self: Controller, categoryId: string, position: int) = proc reorderCommunityCategories*(self: Controller, categoryId: string, position: int) =
self.communityService.reorderCommunityCategories(self.sectionId, categoryId, position) self.communityService.reorderCommunityCategories(self.sectionId, categoryId, position)
@ -717,7 +717,7 @@ proc ownsCollectible*(self: Controller, chainId: int, contractAddress: string, t
for address in addresses: for address in addresses:
let data = self.collectibleService.getOwnedCollectibles(chainId, @[address]) let data = self.collectibleService.getOwnedCollectibles(chainId, @[address])
for collectible in data[0].collectibles: for collectible in data[0].collectibles:
if collectible.id.contractAddress == contractAddress.toLowerAscii: if collectible.id.contractAddress == contractAddress.toLowerAscii:
return true return true
@ -742,4 +742,4 @@ proc getCommunityTokenList*(self: Controller): seq[CommunityTokenDto] =
proc authenticateWithCallback*(self: Controller) = proc authenticateWithCallback*(self: Controller) =
self.tmpAuthenticationWithCallbackInProgress = true self.tmpAuthenticationWithCallbackInProgress = true
self.authenticate() self.authenticate()

View File

@ -101,7 +101,7 @@ method addOrUpdateChat*(self: AccessInterface,
): Item {.base.} = ): Item {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method onNewMessagesReceived*(self: AccessInterface, sectionIdMsgBelongsTo: string, chatIdMsgBelongsTo: string, method onNewMessagesReceived*(self: AccessInterface, sectionIdMsgBelongsTo: string, chatIdMsgBelongsTo: string,
chatTypeMsgBelongsTo: ChatType, lastMessageTimestamp: int, unviewedMessagesCount: int, unviewedMentionsCount: int, message: MessageDto) {.base.} = chatTypeMsgBelongsTo: ChatType, lastMessageTimestamp: int, unviewedMessagesCount: int, unviewedMentionsCount: int, message: MessageDto) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
@ -307,7 +307,7 @@ method exportCommunity*(self: AccessInterface): string {.base.} =
method setCommunityMuted*(self: AccessInterface, mutedType: int) {.base.} = method setCommunityMuted*(self: AccessInterface, mutedType: int) {.base.} =
raise newException(ValueError, "No implementation available") 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") raise newException(ValueError, "No implementation available")
method createCommunityCategory*(self: AccessInterface, name: string, channels: seq[string]) {.base.} = method createCommunityCategory*(self: AccessInterface, name: string, channels: seq[string]) {.base.} =
@ -392,7 +392,7 @@ method editSharedAddressesWithAuthentication*(self: AccessInterface, addressesTo
method onCommunityCheckPermissionsToJoinResponse*(self: AccessInterface, checkPermissionsToJoinResponse: CheckPermissionsToJoinResponseDto) {.base.} = method onCommunityCheckPermissionsToJoinResponse*(self: AccessInterface, checkPermissionsToJoinResponse: CheckPermissionsToJoinResponseDto) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method onCommunityCheckChannelPermissionsResponse*(self: AccessInterface, chatId: string, checkChannelPermissionsResponse: CheckChannelPermissionsResponseDto) {.base.} = method onCommunityCheckChannelPermissionsResponse*(self: AccessInterface, chatId: string, checkChannelPermissionsResponse: CheckChannelPermissionsResponseDto) {.base.} =
@ -405,4 +405,4 @@ method authenticateWithCallback*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method callbackFromAuthentication*(self: AccessInterface, authenticated: bool) {.base.} = method callbackFromAuthentication*(self: AccessInterface, authenticated: bool) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")

View File

@ -282,10 +282,10 @@ proc rebuildCommunityTokenPermissionsModel(self: Module) =
let tokenPermissionItem = buildTokenPermissionItem(tokenPermission, chats) let tokenPermissionItem = buildTokenPermissionItem(tokenPermission, chats)
tokenPermissionsItems.add(tokenPermissionItem) tokenPermissionsItems.add(tokenPermissionItem)
let memberPermissions = filter(tokenPermissionsItems, tokenPermissionsItem => let memberPermissions = filter(tokenPermissionsItems, tokenPermissionsItem =>
tokenPermissionsItem.getType() == TokenPermissionType.BecomeMember.int) tokenPermissionsItem.getType() == TokenPermissionType.BecomeMember.int)
let adminPermissions = filter(tokenPermissionsItems, tokenPermissionsItem => let adminPermissions = filter(tokenPermissionsItems, tokenPermissionsItem =>
tokenPermissionsItem.getType() == TokenPermissionType.BecomeAdmin.int) tokenPermissionsItem.getType() == TokenPermissionType.BecomeAdmin.int)
self.view.tokenPermissionsModel().setItems(tokenPermissionsItems) self.view.tokenPermissionsModel().setItems(tokenPermissionsItems)
@ -442,13 +442,13 @@ method activeItemSet*(self: Module, itemId: string) =
# save last open chat in settings for restore on the next app launch # save last open chat in settings for restore on the next app launch
singletonInstance.localAccountSensitiveSettings.setSectionLastOpenChat(mySectionId, activeChatId) singletonInstance.localAccountSensitiveSettings.setSectionLastOpenChat(mySectionId, activeChatId)
let (deactivateSectionId, deactivateChatId) = singletonInstance.loaderDeactivator.addChatInMemory(mySectionId, activeChatId) let (deactivateSectionId, deactivateChatId) = singletonInstance.loaderDeactivator.addChatInMemory(mySectionId, activeChatId)
# notify parent module about active chat/channel # notify parent module about active chat/channel
self.delegate.onActiveChatChange(mySectionId, activeChatId) self.delegate.onActiveChatChange(mySectionId, activeChatId)
self.delegate.onDeactivateChatLoader(deactivateSectionId, deactivateChatId) self.delegate.onDeactivateChatLoader(deactivateSectionId, deactivateChatId)
if self.controller.isCommunity(): if self.controller.isCommunity():
self.controller.asyncCheckChannelPermissions(mySectionId, activeChatId) self.controller.asyncCheckChannelPermissions(mySectionId, activeChatId)
@ -571,7 +571,7 @@ method addNewChat*(
chatImage = chatDto.icon chatImage = chatDto.icon
var memberRole = self.getUserMemberRole(chatDto.members) var memberRole = self.getUserMemberRole(chatDto.members)
if memberRole == MemberRole.None and len(chatDto.communityId) != 0: if memberRole == MemberRole.None and len(chatDto.communityId) != 0:
memberRole = channelGroup.memberRole memberRole = channelGroup.memberRole
if chatDto.chatType != ChatType.PrivateGroupChat: if chatDto.chatType != ChatType.PrivateGroupChat:
@ -701,7 +701,7 @@ method setFirstChannelAsActive*(self: Module) =
for chat_item in chat_items: for chat_item in chat_items:
if chat_item.`type` != CATEGORY_TYPE: if chat_item.`type` != CATEGORY_TYPE:
self.setActiveItem(chat_item.id) self.setActiveItem(chat_item.id)
break break
method onReorderChat*(self: Module, updatedChat: ChatDto) = method onReorderChat*(self: Module, updatedChat: ChatDto) =
self.view.chatsModel().reorderChats(@[updatedChat]) self.view.chatsModel().reorderChats(@[updatedChat])
@ -788,7 +788,7 @@ method onCommunityTokenPermissionCreated*(self: Module, communityId: string, tok
self.reevaluateRequiresTokenPermissionToJoin() self.reevaluateRequiresTokenPermissionToJoin()
singletonInstance.globalEvents.showCommunityTokenPermissionCreatedNotification(communityId, "Community permission created", "A token permission has been added") singletonInstance.globalEvents.showCommunityTokenPermissionCreatedNotification(communityId, "Community permission created", "A token permission has been added")
proc updateTokenPermissionModel*(self: Module, permissions: Table[string, CheckPermissionsResultDto], community: CommunityDto) = proc updateTokenPermissionModel*(self: Module, permissions: Table[string, CheckPermissionsResultDto], community: CommunityDto) =
for id, criteriaResult in permissions: for id, criteriaResult in permissions:
if community.tokenPermissions.hasKey(id): if community.tokenPermissions.hasKey(id):
let tokenPermissionItem = self.view.tokenPermissionsModel.getItemById(id) let tokenPermissionItem = self.view.tokenPermissionsModel.getItemById(id)
@ -815,7 +815,7 @@ proc updateTokenPermissionModel*(self: Module, permissions: Table[string, CheckP
updatedTokenCriteriaItems.add(updatedTokenCriteriaItem) updatedTokenCriteriaItems.add(updatedTokenCriteriaItem)
let updatedTokenPermissionItem = initTokenPermissionItem( let updatedTokenPermissionItem = initTokenPermissionItem(
tokenPermissionItem.id, tokenPermissionItem.id,
tokenPermissionItem.`type`, tokenPermissionItem.`type`,
updatedTokenCriteriaItems, updatedTokenCriteriaItems,
tokenPermissionItem.getChatList().getItems(), tokenPermissionItem.getChatList().getItems(),
@ -826,18 +826,18 @@ proc updateTokenPermissionModel*(self: Module, permissions: Table[string, CheckP
let tokenPermissionsItems = self.view.tokenPermissionsModel().getItems() let tokenPermissionsItems = self.view.tokenPermissionsModel().getItems()
let memberPermissions = filter(tokenPermissionsItems, tokenPermissionsItem => let memberPermissions = filter(tokenPermissionsItems, tokenPermissionsItem =>
tokenPermissionsItem.getType() == TokenPermissionType.BecomeMember.int) tokenPermissionsItem.getType() == TokenPermissionType.BecomeMember.int)
let adminPermissions = filter(tokenPermissionsItems, tokenPermissionsItem => let adminPermissions = filter(tokenPermissionsItems, tokenPermissionsItem =>
tokenPermissionsItem.getType() == TokenPermissionType.BecomeAdmin.int) tokenPermissionsItem.getType() == TokenPermissionType.BecomeAdmin.int)
# multiple permissions of the same type act as logical OR # multiple permissions of the same type act as logical OR
# so if at least one of them is fulfilled we can mark the view # so if at least one of them is fulfilled we can mark the view
# as all lights green # as all lights green
let memberRequirementMet = memberPermissions.len() > 0 and any(memberPermissions, let memberRequirementMet = memberPermissions.len() > 0 and any(memberPermissions,
proc (item: TokenPermissionItem): bool = item.tokenCriteriaMet) proc (item: TokenPermissionItem): bool = item.tokenCriteriaMet)
let adminRequirementMet = adminPermissions.len() > 0 and any(adminPermissions, proc (item: TokenPermissionItem): bool = item.tokenCriteriaMet) let adminRequirementMet = adminPermissions.len() > 0 and any(adminPermissions, proc (item: TokenPermissionItem): bool = item.tokenCriteriaMet)
let requiresPermissionToJoin = (adminPermissions.len() > 0 and adminRequirementMet) or memberPermissions.len() > 0 let requiresPermissionToJoin = (adminPermissions.len() > 0 and adminRequirementMet) or memberPermissions.len() > 0
@ -845,7 +845,7 @@ proc updateTokenPermissionModel*(self: Module, permissions: Table[string, CheckP
self.view.setAllTokenRequirementsMet(tokenRequirementsMet) self.view.setAllTokenRequirementsMet(tokenRequirementsMet)
self.view.setRequiresTokenPermissionToJoin(requiresPermissionToJoin) self.view.setRequiresTokenPermissionToJoin(requiresPermissionToJoin)
proc updateChannelPermissionViewData*(self: Module, chatId: string, viewOnlyPermissions: ViewOnlyOrViewAndPostPermissionsResponseDto, viewAndPostPermissions: ViewOnlyOrViewAndPostPermissionsResponseDto, community: CommunityDto) = proc updateChannelPermissionViewData*(self: Module, chatId: string, viewOnlyPermissions: ViewOnlyOrViewAndPostPermissionsResponseDto, viewAndPostPermissions: ViewOnlyOrViewAndPostPermissionsResponseDto, community: CommunityDto) =
self.updateTokenPermissionModel(viewOnlyPermissions.permissions, community) self.updateTokenPermissionModel(viewOnlyPermissions.permissions, community)
@ -1119,8 +1119,8 @@ method exportCommunity*(self: Module): string =
method setCommunityMuted*(self: Module, mutedType: int) = method setCommunityMuted*(self: Module, mutedType: int) =
self.controller.setCommunityMuted(mutedType) self.controller.setCommunityMuted(mutedType)
method inviteUsersToCommunity*(self: Module, pubKeysJSON: string, inviteMessage: string): string = method shareCommunityToUsers*(self: Module, pubKeysJSON: string, inviteMessage: string): string =
result = self.controller.inviteUsersToCommunity(pubKeysJSON, inviteMessage) result = self.controller.shareCommunityToUsers(pubKeysJSON, inviteMessage)
method prepareEditCategoryModel*(self: Module, categoryId: string) = method prepareEditCategoryModel*(self: Module, categoryId: string) =
self.view.editCategoryChannelsModel().clearItems() self.view.editCategoryChannelsModel().clearItems()
@ -1317,14 +1317,14 @@ method createOrEditCommunityTokenPermission*(self: Module, communityId: string,
if contractAddresses.len == 0 and tokenCriteriaDto.`type` != community_dto.TokenType.ENS: if contractAddresses.len == 0 and tokenCriteriaDto.`type` != community_dto.TokenType.ENS:
if permissionId == "": if permissionId == "":
self.onCommunityTokenPermissionCreationFailed(communityId) self.onCommunityTokenPermissionCreationFailed(communityId)
return return
self.onCommunityTokenPermissionUpdateFailed(communityId) self.onCommunityTokenPermissionUpdateFailed(communityId)
return return
tokenCriteriaDto.amount = viewAmount.formatBiggestFloat(ffDecimal) tokenCriteriaDto.amount = viewAmount.formatBiggestFloat(ffDecimal)
tokenCriteriaDto.contractAddresses = contractAddresses tokenCriteriaDto.contractAddresses = contractAddresses
tokenPermission.tokenCriteria.add(tokenCriteriaDto) tokenPermission.tokenCriteria.add(tokenCriteriaDto)
self.controller.createOrEditCommunityTokenPermission(communityId, tokenPermission) self.controller.createOrEditCommunityTokenPermission(communityId, tokenPermission)
method deleteCommunityTokenPermission*(self: Module, communityId: string, permissionId: string) = method deleteCommunityTokenPermission*(self: Module, communityId: string, permissionId: string) =
@ -1344,4 +1344,4 @@ method authenticateWithCallback*(self: Module) =
self.controller.authenticateWithCallback() self.controller.authenticateWithCallback()
method callbackFromAuthentication*(self: Module, authenticated: bool) = method callbackFromAuthentication*(self: Module, authenticated: bool) =
self.view.callbackFromAuthentication(authenticated) self.view.callbackFromAuthentication(authenticated)

View File

@ -20,14 +20,14 @@ QtObject:
listOfMyContactsVariant: QVariant listOfMyContactsVariant: QVariant
editCategoryChannelsModel: chats_model.Model editCategoryChannelsModel: chats_model.Model
editCategoryChannelsVariant: QVariant editCategoryChannelsVariant: QVariant
loadingHistoryMessagesInProgress: bool loadingHistoryMessagesInProgress: bool
tokenPermissionsModel: TokenPermissionsModel tokenPermissionsModel: TokenPermissionsModel
tokenPermissionsVariant: QVariant tokenPermissionsVariant: QVariant
allTokenRequirementsMet: bool allTokenRequirementsMet: bool
requiresTokenPermissionToJoin: bool requiresTokenPermissionToJoin: bool
amIMember: bool amIMember: bool
chatsLoaded: bool chatsLoaded: bool
proc delete*(self: View) = proc delete*(self: View) =
self.model.delete self.model.delete
self.modelVariant.delete self.modelVariant.delete
@ -303,7 +303,7 @@ QtObject:
proc leaveCommunity*(self: View) {.slot.} = proc leaveCommunity*(self: View) {.slot.} =
self.delegate.leaveCommunity() self.delegate.leaveCommunity()
proc removeUserFromCommunity*(self: View, pubKey: string) {.slot.} = proc removeUserFromCommunity*(self: View, pubKey: string) {.slot.} =
self.delegate.removeUserFromCommunity(pubKey) self.delegate.removeUserFromCommunity(pubKey)
@ -311,7 +311,7 @@ QtObject:
self.delegate.banUserFromCommunity(pubKey) self.delegate.banUserFromCommunity(pubKey)
proc editCommunity*(self: View, name: string, description: string, introMessage: string, outroMessage: string, access: int, proc editCommunity*(self: View, name: string, description: string, introMessage: string, outroMessage: string, access: int,
color: string, tags: string, logoJsonData: string, bannerJsonData: string, historyArchiveSupportEnabled: bool, color: string, tags: string, logoJsonData: string, bannerJsonData: string, historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool) {.slot.} = pinMessageAllMembersEnabled: bool) {.slot.} =
self.delegate.editCommunity(name, description, introMessage, outroMessage, access, color, tags, self.delegate.editCommunity(name, description, introMessage, outroMessage, access, color, tags,
logoJsonData, bannerJsonData, historyArchiveSupportEnabled, pinMessageAllMembersEnabled) logoJsonData, bannerJsonData, historyArchiveSupportEnabled, pinMessageAllMembersEnabled)
@ -325,8 +325,8 @@ QtObject:
proc setCommunityMuted*(self: View, mutedType: int) {.slot.} = proc setCommunityMuted*(self: View, mutedType: int) {.slot.} =
self.delegate.setCommunityMuted(mutedType) self.delegate.setCommunityMuted(mutedType)
proc inviteUsersToCommunity*(self: View, pubKeysJSON: string, inviteMessage: string): string {.slot.} = proc shareCommunityToUsers*(self: View, pubKeysJSON: string, inviteMessage: string): string {.slot.} =
result = self.delegate.inviteUsersToCommunity(pubKeysJSON, inviteMessage) result = self.delegate.shareCommunityToUsers(pubKeysJSON, inviteMessage)
proc createCommunityCategory*(self: View, name: string, channels: string) {.slot.} = proc createCommunityCategory*(self: View, name: string, channels: string) {.slot.} =
let channelsSeq = map(parseJson(channels).getElems(), proc(x:JsonNode):string = x.getStr()) let channelsSeq = map(parseJson(channels).getElems(), proc(x:JsonNode):string = x.getStr())
@ -347,12 +347,12 @@ QtObject:
proc reorderCommunityChat*(self: View, categoryId: string, chatId: string, position: int) {.slot} = proc reorderCommunityChat*(self: View, categoryId: string, chatId: string, position: int) {.slot} =
self.delegate.reorderCommunityChat(categoryId, chatId, position) self.delegate.reorderCommunityChat(categoryId, chatId, position)
proc loadingHistoryMessagesInProgressChanged*(self: View) {.signal.} proc loadingHistoryMessagesInProgressChanged*(self: View) {.signal.}
proc getLoadingHistoryMessagesInProgress*(self: View): bool {.slot.} = proc getLoadingHistoryMessagesInProgress*(self: View): bool {.slot.} =
return self.loadingHistoryMessagesInProgress return self.loadingHistoryMessagesInProgress
QtProperty[bool] loadingHistoryMessagesInProgress: QtProperty[bool] loadingHistoryMessagesInProgress:
read = getLoadingHistoryMessagesInProgress read = getLoadingHistoryMessagesInProgress
notify = loadingHistoryMessagesInProgressChanged notify = loadingHistoryMessagesInProgressChanged
@ -408,7 +408,7 @@ QtObject:
return return
self.amIMember = value self.amIMember = value
self.amIMemberChanged() self.amIMemberChanged()
QtProperty[bool] amIMember: QtProperty[bool] amIMember:
read = getAmIMember read = getAmIMember
notify = amIMemberChanged notify = amIMemberChanged
@ -423,7 +423,7 @@ QtObject:
return return
self.allTokenRequirementsMet = value self.allTokenRequirementsMet = value
self.allTokenRequirementsMetChanged() self.allTokenRequirementsMetChanged()
QtProperty[bool] allTokenRequirementsMet: QtProperty[bool] allTokenRequirementsMet:
read = getAllTokenRequirementsMet read = getAllTokenRequirementsMet
notify = allTokenRequirementsMetChanged notify = allTokenRequirementsMetChanged
@ -432,5 +432,5 @@ QtObject:
proc authenticateWithCallback*(self: View) {.slot.} = proc authenticateWithCallback*(self: View) {.slot.} =
self.delegate.authenticateWithCallback() self.delegate.authenticateWithCallback()
proc callbackFromAuthentication*(self: View, authenticated: bool) {.signal.} proc callbackFromAuthentication*(self: View, authenticated: bool) {.signal.}

View File

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

View File

@ -22,7 +22,7 @@ method getModuleAsVariant*(self: AccessInterface): QVariant {.base.} =
method viewDidLoad*(self: AccessInterface) {.base.} = method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available") 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") raise newException(ValueError, "No implementation available")
method leaveCommunity*(self: AccessInterface, communityID: string) {.base.} = method leaveCommunity*(self: AccessInterface, communityID: string) {.base.} =

View File

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

View File

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

View File

@ -257,7 +257,7 @@ QtObject:
self.events.emit(SIGNAL_COMMUNITY_DATA_IMPORTED, CommunityArgs(community: receivedData.community)) self.events.emit(SIGNAL_COMMUNITY_DATA_IMPORTED, CommunityArgs(community: receivedData.community))
if self.communities.contains(receivedData.community.id) and if self.communities.contains(receivedData.community.id) and
self.communities[receivedData.community.id].listedInDirectory and not self.communities[receivedData.community.id].listedInDirectory and not
self.communities[receivedData.community.id].isAvailable: self.communities[receivedData.community.id].isAvailable:
self.events.emit(SIGNAL_CURATED_COMMUNITY_FOUND, CommunityArgs(community: self.communities[receivedData.community.id])) self.events.emit(SIGNAL_CURATED_COMMUNITY_FOUND, CommunityArgs(community: self.communities[receivedData.community.id]))
@ -292,7 +292,7 @@ QtObject:
community.pendingRequestsToJoin.delete(indexPending) community.pendingRequestsToJoin.delete(indexPending)
self.communities[membershipRequest.communityId] = community self.communities[membershipRequest.communityId] = community
self.events.emit(SIGNAL_COMMUNITY_EDITED, CommunityArgs(community: community)) self.events.emit(SIGNAL_COMMUNITY_EDITED, CommunityArgs(community: community))
of RequestToJoinType.Declined: of RequestToJoinType.Declined:
break break
of RequestToJoinType.Accepted: of RequestToJoinType.Accepted:
@ -436,7 +436,7 @@ QtObject:
self.events.emit(SIGNAL_COMMUNITY_CATEGORY_NAME_EDITED, self.events.emit(SIGNAL_COMMUNITY_CATEGORY_NAME_EDITED,
CommunityCategoryArgs(communityId: community.id, category: category)) CommunityCategoryArgs(communityId: community.id, category: category))
proc handleCommunityUpdates(self: Service, communities: seq[CommunityDto], updatedChats: seq[ChatDto], removedChats: seq[string]) = proc handleCommunityUpdates(self: Service, communities: seq[CommunityDto], updatedChats: seq[ChatDto], removedChats: seq[string]) =
try: try:
var community = communities[0] var community = communities[0]
@ -552,7 +552,7 @@ QtObject:
# members list was changed # members list was changed
if (community.isMember or community.tokenPermissions.len == 0) and community.members != prev_community.members: if (community.isMember or community.tokenPermissions.len == 0) and community.members != prev_community.members:
self.events.emit(SIGNAL_COMMUNITY_MEMBERS_CHANGED, self.events.emit(SIGNAL_COMMUNITY_MEMBERS_CHANGED,
CommunityMembersArgs(communityId: community.id, members: community.members)) CommunityMembersArgs(communityId: community.id, members: community.members))
# token metadata was added # token metadata was added
@ -608,7 +608,7 @@ QtObject:
if permissionUpdated: if permissionUpdated:
self.communities[community.id].tokenPermissions[id] = tokenPermission self.communities[community.id].tokenPermissions[id] = tokenPermission
self.events.emit(SIGNAL_COMMUNITY_TOKEN_PERMISSION_UPDATED, self.events.emit(SIGNAL_COMMUNITY_TOKEN_PERMISSION_UPDATED,
CommunityTokenPermissionArgs(communityId: community.id, tokenPermission: tokenPermission)) CommunityTokenPermissionArgs(communityId: community.id, tokenPermission: tokenPermission))
let wasJoined = self.communities[community.id].joined let wasJoined = self.communities[community.id].joined
@ -622,7 +622,7 @@ QtObject:
self.events.emit(SIGNAL_COMMUNITIES_UPDATE, CommunitiesArgs(communities: @[community])) self.events.emit(SIGNAL_COMMUNITIES_UPDATE, CommunitiesArgs(communities: @[community]))
if wasJoined and not community.joined and not community.isMember: if wasJoined and not community.joined and not community.isMember:
self.events.emit(SIGNAL_COMMUNITY_KICKED, CommunityArgs(community: community)) self.events.emit(SIGNAL_COMMUNITY_KICKED, CommunityArgs(community: community))
except Exception as e: except Exception as e:
error "Error handling community updates", msg = e.msg error "Error handling community updates", msg = e.msg
@ -735,7 +735,7 @@ QtObject:
else: else:
return 0 return 0
proc getCategoryById*(self: Service, communityId: string, categoryId: string): Category = proc getCategoryById*(self: Service, communityId: string, categoryId: string): Category =
if(not self.communities.contains(communityId)): if(not self.communities.contains(communityId)):
error "trying to get community categories for an unexisting community id" error "trying to get community categories for an unexisting community id"
return return
@ -1018,7 +1018,7 @@ QtObject:
self.communities[community.id] = community self.communities[community.id] = community
# add new community channel group and chats to chat service # add new community channel group and chats to chat service
self.chatService.updateOrAddChannelGroup(community.toChannelGroupDto()) self.chatService.updateOrAddChannelGroup(community.toChannelGroupDto())
for chat in community.chats: for chat in community.chats:
self.chatService.updateOrAddChat(chat) self.chatService.updateOrAddChat(chat)
self.events.emit(SIGNAL_COMMUNITY_CREATED, CommunityArgs(community: community)) self.events.emit(SIGNAL_COMMUNITY_CREATED, CommunityArgs(community: community))
@ -1201,7 +1201,7 @@ QtObject:
chatDetails.updateMissingFields(self.communities[communityId].chats[prev_chat_idx]) chatDetails.updateMissingFields(self.communities[communityId].chats[prev_chat_idx])
self.chatService.updateOrAddChat(chatDetails) # we have to update chats stored in the chat service. self.chatService.updateOrAddChat(chatDetails) # we have to update chats stored in the chat service.
updatedChats.add(chat) updatedChats.add(chat)
self.events.emit(SIGNAL_COMMUNITY_CHANNELS_REORDERED, self.events.emit(SIGNAL_COMMUNITY_CHANNELS_REORDERED,
CommunityChatsOrderArgs(communityId: updatedCommunity.id, chats: updatedChats)) CommunityChatsOrderArgs(communityId: updatedCommunity.id, chats: updatedChats))
@ -1374,7 +1374,7 @@ QtObject:
community.id = requestedCommunityId community.id = requestedCommunityId
self.events.emit(SIGNAL_COMMUNITY_LOAD_DATA_FAILED, CommunityArgs(community: community, error: "Couldn't find community info")) self.events.emit(SIGNAL_COMMUNITY_LOAD_DATA_FAILED, CommunityArgs(community: community, error: "Couldn't find community info"))
return return
self.communities[community.id] = community self.communities[community.id] = community
if rpcResponseObj{"importing"}.getBool(): if rpcResponseObj{"importing"}.getBool():
@ -1421,8 +1421,8 @@ QtObject:
) )
self.threadpool.start(arg) self.threadpool.start(arg)
except Exception as e: except Exception as e:
error "Error request to join community", msg = e.msg error "Error request to join community", msg = e.msg
proc onAsyncRequestToJoinCommunityDone*(self: Service, communityIdAndRpcResponse: string) {.slot.} = proc onAsyncRequestToJoinCommunityDone*(self: Service, communityIdAndRpcResponse: string) {.slot.} =
let rpcResponseObj = communityIdAndRpcResponse.parseJson let rpcResponseObj = communityIdAndRpcResponse.parseJson
try: try:
@ -1431,7 +1431,7 @@ QtObject:
let rpcResponse = Json.decode($rpcResponseObj["response"], RpcResponse[JsonNode]) let rpcResponse = Json.decode($rpcResponseObj["response"], RpcResponse[JsonNode])
self.activityCenterService.parseActivityCenterResponse(rpcResponse) self.activityCenterService.parseActivityCenterResponse(rpcResponse)
if not self.processRequestsToJoinCommunity(rpcResponse.result): if not self.processRequestsToJoinCommunity(rpcResponse.result):
raise newException(CatchableError, "no 'requestsToJoinCommunity' key in response") raise newException(CatchableError, "no 'requestsToJoinCommunity' key in response")
@ -1454,7 +1454,7 @@ QtObject:
airdropAddress: airdropAddress, airdropAddress: airdropAddress,
) )
self.threadpool.start(arg) self.threadpool.start(arg)
proc onAsyncEditSharedAddressesDone*(self: Service, communityIdAndRpcResponse: string) {.slot.} = proc onAsyncEditSharedAddressesDone*(self: Service, communityIdAndRpcResponse: string) {.slot.} =
let rpcResponseObj = communityIdAndRpcResponse.parseJson let rpcResponseObj = communityIdAndRpcResponse.parseJson
try: try:
@ -1485,7 +1485,7 @@ QtObject:
) )
self.threadpool.start(arg) self.threadpool.start(arg)
except Exception as e: except Exception as e:
error "Error accepting request to join community", msg = e.msg error "Error accepting request to join community", msg = e.msg
proc onAsyncAcceptRequestToJoinCommunityDone*(self: Service, response: string) {.slot.} = proc onAsyncAcceptRequestToJoinCommunityDone*(self: Service, response: string) {.slot.} =
var communityId: string var communityId: string
@ -1504,7 +1504,7 @@ QtObject:
else: else:
self.events.emit(SIGNAL_ACCEPT_REQUEST_TO_JOIN_FAILED, CommunityMemberArgs(communityId: communityId, pubKey: userKey, requestId: requestId)) self.events.emit(SIGNAL_ACCEPT_REQUEST_TO_JOIN_FAILED, CommunityMemberArgs(communityId: communityId, pubKey: userKey, requestId: requestId))
return return
discard self.removeMembershipRequestFromCommunityAndGetMemberPubkey(communityId, requestId, discard self.removeMembershipRequestFromCommunityAndGetMemberPubkey(communityId, requestId,
rpcResponseObj["response"]["result"]["communities"][0].toCommunityDto) rpcResponseObj["response"]["result"]["communities"][0].toCommunityDto)
@ -1533,7 +1533,7 @@ QtObject:
) )
self.threadpool.start(arg) self.threadpool.start(arg)
except Exception as e: except Exception as e:
error "Error loading curated communities", msg = e.msg error "Error loading curated communities", msg = e.msg
proc onAsyncLoadCuratedCommunitiesDone*(self: Service, response: string) {.slot.} = proc onAsyncLoadCuratedCommunitiesDone*(self: Service, response: string) {.slot.} =
try: try:
@ -1730,7 +1730,7 @@ QtObject:
return return
i.inc() i.inc()
except Exception as e: except Exception as e:
error "Error canceled request to join community", msg = e.msg error "Error canceled request to join community", msg = e.msg
@ -1745,7 +1745,7 @@ QtObject:
except Exception as e: except Exception as e:
error "Error declining request to join community", msg = e.msg 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: try:
let pubKeysParsed = pubKeysJson.parseJson let pubKeysParsed = pubKeysJson.parseJson
var pubKeys: seq[string] = @[] var pubKeys: seq[string] = @[]
@ -1812,7 +1812,7 @@ QtObject:
if not response.error.isNil: if not response.error.isNil:
error "error muting the community", msg = response.error.message error "error muting the community", msg = response.error.message
return return
let muted = if (MutedType(mutedType) == MutedType.Unmuted): false else: true let muted = if (MutedType(mutedType) == MutedType.Unmuted): false else: true
self.events.emit(SIGNAL_COMMUNITY_MUTED, self.events.emit(SIGNAL_COMMUNITY_MUTED,
CommunityMutedArgs(communityId: communityId, muted: muted)) CommunityMutedArgs(communityId: communityId, muted: muted))

View File

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

View File

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

View File

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