diff --git a/src/app/modules/main/communities/module.nim b/src/app/modules/main/communities/module.nim index 002b09eefb..b6ac7a316f 100644 --- a/src/app/modules/main/communities/module.nim +++ b/src/app/modules/main/communities/module.nim @@ -258,7 +258,8 @@ proc getCuratedCommunityItem(self: Module, community: CommunityDto): CuratedComm let myPublicKey = singletonInstance.userProfile.getPubKey() var amIbanned = false if myPublicKey in community.pendingAndBannedMembers: - amIbanned = community.pendingAndBannedMembers[myPublicKey] == CommunityMemberPendingBanOrKick.Banned + let state = community.pendingAndBannedMembers[myPublicKey] + amIbanned = isBanned(state) return initCuratedCommunityItem( community.id, diff --git a/src/app/modules/main/controller.nim b/src/app/modules/main/controller.nim index 9206f7e67d..8a509301bd 100644 --- a/src/app/modules/main/controller.nim +++ b/src/app/modules/main/controller.nim @@ -407,7 +407,7 @@ proc init*(self: Controller) = self.events.on(SIGNAL_COMMUNITY_MEMBER_STATUS_CHANGED) do(e: Args): let args = CommunityMemberStatusUpdatedArgs(e) - self.delegate.onMembershipStatusUpdated(args.communityId, args.memberPubkey, args.status) + self.delegate.onMembershipStateUpdated(args.communityId, args.memberPubkey, args.state) self.events.on(SIGNAL_COMMUNITY_MEMBERS_CHANGED) do(e: Args): let args = CommunityMembersArgs(e) diff --git a/src/app/modules/main/io_interface.nim b/src/app/modules/main/io_interface.nim index dfb25e4d2c..a42ac63b67 100644 --- a/src/app/modules/main/io_interface.nim +++ b/src/app/modules/main/io_interface.nim @@ -376,7 +376,7 @@ method onAcceptRequestToJoinLoading*(self: AccessInterface, communityId: string, method onAcceptRequestToJoinSuccess*(self: AccessInterface, communityId: string, memberKey: string, requestId: string) {.base.} = raise newException(ValueError, "No implementation available") -method onMembershipStatusUpdated*(self: AccessInterface, communityId: string, memberPubkey: string, status: MembershipRequestState) {.base.} = +method onMembershipStateUpdated*(self: AccessInterface, communityId: string, memberPubkey: string, state: MembershipRequestState) {.base.} = raise newException(ValueError, "No implementation available") method onDeactivateChatLoader*(self: AccessInterface, sectionId: string, chatId: string) {.base.} = diff --git a/src/app/modules/main/module.nim b/src/app/modules/main/module.nim index aa097e3b8b..694167b904 100644 --- a/src/app/modules/main/module.nim +++ b/src/app/modules/main/module.nim @@ -348,8 +348,11 @@ proc createChannelGroupItem[T](self: Module[T], channelGroup: ChannelGroupDto): var bannedMembers = newSeq[MemberItem]() for memberId, memberState in communityDetails.pendingAndBannedMembers.pairs: let state = memberState.toMembershipRequestState() - if state == MembershipRequestState.Banned or state == MembershipRequestState.UnbannedPending: - bannedMembers.add(self.createMemberItem(memberId, state, MemberRole.None)) + case state: + of MembershipRequestState.Banned, MembershipRequestState.BannedWithAllMessagesDelete, MembershipRequestState.UnbannedPending: + bannedMembers.add(self.createMemberItem(memberId, state, MemberRole.None)) + else: + discard result = initItem( channelGroup.id, @@ -1233,13 +1236,13 @@ method onAcceptRequestToJoinSuccess*[T](self: Module[T], communityId: string, me if item.id != "": item.updatePendingRequestLoadingState(memberKey, false) -method onMembershipStatusUpdated*[T](self: Module[T], communityId: string, memberPubkey: string, status: MembershipRequestState) = +method onMembershipStateUpdated*[T](self: Module[T], communityId: string, memberPubkey: string, state: MembershipRequestState) = let myPublicKey = singletonInstance.userProfile.getPubKey() let communityDto = self.controller.getCommunityById(communityId) if myPublicKey == memberPubkey: - case status: - of MembershipRequestState.Banned: + case state: + of MembershipRequestState.Banned, MembershipRequestState.BannedWithAllMessagesDelete: singletonInstance.globalEvents.showCommunityMemberBannedNotification(fmt "You've been banned from {communityDto.name}", "", communityId) of MembershipRequestState.Kicked: singletonInstance.globalEvents.showCommunityMemberKickedNotification(fmt "You were kicked from {communityDto.name}", "", communityId) @@ -1251,9 +1254,13 @@ method onMembershipStatusUpdated*[T](self: Module[T], communityId: string, membe let (contactName, _, _) = self.controller.getContactNameAndImage(memberPubkey) let item = self.view.model().getItemById(communityId) if item.id != "": - item.updateMembershipStatus(memberPubkey, status) - if status == MembershipRequestState.Banned or status == MembershipRequestState.Kicked or status == MembershipRequestState.Unbanned: - self.view.emitCommunityMemberStatusEphemeralNotification(communityDto.name, contactName, status.int) + item.updateMembershipStatus(memberPubkey, state) + case state: + of MembershipRequestState.Banned, MembershipRequestState.Kicked, + MembershipRequestState.Unbanned, MembershipRequestState.BannedWithAllMessagesDelete: + self.view.emitCommunityMemberStatusEphemeralNotification(communityDto.name, contactName, state.int) + else: + discard method calculateProfileSectionHasNotification*[T](self: Module[T]): bool = return not self.controller.isMnemonicBackedUp() diff --git a/src/app/modules/shared_models/section_item.nim b/src/app/modules/shared_models/section_item.nim index 8a970e1cc3..3f03f23f91 100644 --- a/src/app/modules/shared_models/section_item.nim +++ b/src/app/modules/shared_models/section_item.nim @@ -287,10 +287,10 @@ proc access*(self: SectionItem): int {.inline.} = proc ensOnly*(self: SectionItem): bool {.inline.} = self.ensOnly -proc muted*(self: SectionItem): bool {.inline.} = +proc muted*(self: SectionItem): bool {.inline.} = self.muted -proc `muted=`*(self: var SectionItem, value: bool) {.inline.} = +proc `muted=`*(self: var SectionItem, value: bool) {.inline.} = self.muted = value proc members*(self: SectionItem): member_model.Model {.inline.} = @@ -380,11 +380,12 @@ proc communityTokens*(self: SectionItem): community_tokens_model.TokenModel {.in proc updatePendingRequestLoadingState*(self: SectionItem, memberKey: string, loading: bool) {.inline.} = self.pendingMemberRequestsModel.updateLoadingState(memberKey, loading) -proc updateMembershipStatus*(self: SectionItem, memberKey: string, status: MembershipRequestState) {.inline.} = - if status == MembershipRequestState.UnbannedPending or status == MembershipRequestState.Banned: - self.bannedMembersModel.updateMembershipStatus(memberKey, status) - else: - self.membersModel.updateMembershipStatus(memberKey, status) +proc updateMembershipStatus*(self: SectionItem, memberKey: string, state: MembershipRequestState) {.inline.} = + case state: + of MembershipRequestState.Banned, MembershipRequestState.BannedWithAllMessagesDelete, MembershipRequestState.UnbannedPending: + self.bannedMembersModel.updateMembershipStatus(memberKey, state) + else: + self.membersModel.updateMembershipStatus(memberKey, state) proc pubsubTopic*(self: SectionItem): string {.inline.} = self.pubsubTopic diff --git a/src/app_service/common/types.nim b/src/app_service/common/types.nim index ad83b77418..a65256f801 100644 --- a/src/app_service/common/types.nim +++ b/src/app_service/common/types.nim @@ -72,6 +72,7 @@ type MembershipRequestState* {.pure} = enum KickedPending = 10, AwaitingAddress = 11, Unbanned = 12, + BannedWithAllMessagesDelete = 13 type ContractTransactionStatus* {.pure.} = enum diff --git a/src/app_service/service/community/dto/community.nim b/src/app_service/service/community/dto/community.nim index 56c20da6d4..ce55299e13 100644 --- a/src/app_service/service/community/dto/community.nim +++ b/src/app_service/service/community/dto/community.nim @@ -40,9 +40,11 @@ type Banned = 0, BanPending, UnbanPending, - KickPending - Unbanned, - Kicked + KickPending, + BannedWithAllMessagesDelete + +proc isBanned*(state: CommunityMemberPendingBanOrKick): bool = + return state == CommunityMemberPendingBanOrKick.Banned or state == CommunityMemberPendingBanOrKick.BannedWithAllMessagesDelete type CommunityMembershipRequestDto* = object id*: string @@ -481,6 +483,8 @@ proc toMembershipRequestState*(state: CommunityMemberPendingBanOrKick): Membersh return MembershipRequestState.UnbannedPending of CommunityMemberPendingBanOrKick.KickPending: return MembershipRequestState.KickedPending + of CommunityMemberPendingBanOrKick.BannedWithAllMessagesDelete: + return MembershipRequestState.BannedWithAllMessagesDelete else: return MembershipRequestState.None @@ -526,7 +530,7 @@ proc contains(arrayToSearch: seq[int], searched: int): bool = proc getBannedMembersIds*(self: CommunityDto): seq[string] = var bannedIds: seq[string] = @[] for memberId, state in self.pendingAndBannedMembers: - if state == CommunityMemberPendingBanOrKick.Banned: + if isBanned(state): bannedIds.add(memberId) return bannedIds @@ -646,4 +650,4 @@ proc findOwner*(self: CommunityDto): ChatMember = for member in self.members: if member.role == MemberRole.Owner: return member - raise newException(ValueError, "No owner found in members list") \ No newline at end of file + raise newException(ValueError, "No owner found in members list") diff --git a/src/app_service/service/community/service.nim b/src/app_service/service/community/service.nim index ef9c372592..d19fb23781 100644 --- a/src/app_service/service/community/service.nim +++ b/src/app_service/service/community/service.nim @@ -161,7 +161,7 @@ type CommunityMemberStatusUpdatedArgs* = ref object of Args communityId*: string memberPubkey*: string - status*: MembershipRequestState + state*: MembershipRequestState CommunityShardSetArgs* = ref object of Args communityId*: string @@ -745,15 +745,16 @@ QtObject: else: # We were kicked or banned, leave the community self.events.emit(SIGNAL_COMMUNITY_LEFT, CommunityIdArgs(communityId: community.id)) - var status = MembershipRequestState.Kicked - if community.pendingAndBannedMembers.hasKey(myPublicKey) and - community.pendingAndBannedMembers[myPublicKey] == CommunityMemberPendingBanOrKick.Banned: - status = MembershipRequestState.Banned + var state = MembershipRequestState.Kicked + if community.pendingAndBannedMembers.hasKey(myPublicKey): + let status = community.pendingAndBannedMembers[myPublicKey] + if isBanned(status): + state = status.toMembershipRequestState() self.events.emit(SIGNAL_COMMUNITY_MEMBER_STATUS_CHANGED, CommunityMemberStatusUpdatedArgs( communityId: community.id, memberPubkey: myPublicKey, - status: status)) + state: state)) # Check if we were unbanned if not wasJoined and not community.joined and prevCommunity.pendingAndBannedMembers.hasKey(myPublicKey) and not @@ -761,7 +762,7 @@ QtObject: self.events.emit(SIGNAL_COMMUNITY_MEMBER_STATUS_CHANGED, CommunityMemberStatusUpdatedArgs( communityId: community.id, memberPubkey: myPublicKey, - status: MembershipRequestState.Unbanned)) + state: MembershipRequestState.Unbanned)) except Exception as e: error "Error handling community updates", msg = e.msg @@ -2166,21 +2167,21 @@ QtObject: var community = communityJArr[0].toCommunityDto() - var status: MembershipRequestState = MembershipRequestState.None + var state: MembershipRequestState = MembershipRequestState.None if community.pendingAndBannedMembers.hasKey(memberPubkey): - status = community.pendingAndBannedMembers[memberPubkey].toMembershipRequestState() + state = community.pendingAndBannedMembers[memberPubkey].toMembershipRequestState() - if status == MembershipRequestState.None: + if state == MembershipRequestState.None: let prevCommunity = self.communities[community.id] if prevCommunity.pendingAndBannedMembers.hasKey(memberPubkey): - status = MembershipRequestState.Unbanned + state = MembershipRequestState.Unbanned elif len(prevCommunity.members) > len(community.members): - status = MembershipRequestState.Kicked + state = MembershipRequestState.Kicked self.events.emit(SIGNAL_COMMUNITY_MEMBER_STATUS_CHANGED, CommunityMemberStatusUpdatedArgs( communityId: community.id, memberPubkey: memberPubkey, - status: status + state: state )) except Exception as e: diff --git a/ui/app/AppLayouts/Communities/panels/MembersTabPanel.qml b/ui/app/AppLayouts/Communities/panels/MembersTabPanel.qml index 13849a8643..b29a0a8f26 100644 --- a/ui/app/AppLayouts/Communities/panels/MembersTabPanel.qml +++ b/ui/app/AppLayouts/Communities/panels/MembersTabPanel.qml @@ -104,7 +104,8 @@ Item { readonly property bool isBanPending: model.membershipRequestState === Constants.CommunityMembershipRequestState.BannedPending readonly property bool isUnbanPending: model.membershipRequestState === Constants.CommunityMembershipRequestState.UnbannedPending readonly property bool isKickPending: model.membershipRequestState === Constants.CommunityMembershipRequestState.KickedPending - readonly property bool isBanned: model.membershipRequestState === Constants.CommunityMembershipRequestState.Banned + readonly property bool isBanned: model.membershipRequestState === Constants.CommunityMembershipRequestState.Banned || + model.membershipRequestState === Constants.CommunityMembershipRequestState.BannedWithAllMessagesDelete readonly property bool isKicked: model.membershipRequestState === Constants.CommunityMembershipRequestState.Kicked // TODO: Connect to backend when available diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index 71eba50a4b..48f593f200 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -229,6 +229,7 @@ Item { var text = "" switch (state) { case Constants.CommunityMembershipRequestState.Banned: + case Constants.CommunityMembershipRequestState.BannedWithAllMessagesDelete: text = qsTr("%1 was banned from %2").arg(memberName).arg(communityName) break case Constants.CommunityMembershipRequestState.Unbanned: diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index fd9dd3cf99..311c35cc65 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -1226,7 +1226,8 @@ QtObject { UnbannedPending, KickedPending, AwaitingAddress, - Unbanned + Unbanned, + BannedWithAllMessagesDelete } readonly property QtObject walletAccountColors: QtObject { diff --git a/vendor/status-go b/vendor/status-go index f0d6a4f64f..a1033f466a 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit f0d6a4f64f882fe249626a5fec8eaafba3f97824 +Subproject commit a1033f466a7814d8194938f49abe28ea322272d5