From 243ff6799de864e47a765245724519405c510330 Mon Sep 17 00:00:00 2001 From: Mykhailo Prakhov Date: Fri, 5 Jul 2024 15:25:30 +0200 Subject: [PATCH] fix(reevaluateMembers)_: changing privileged permissions (TM -> admin, admin -> TM) --- protocol/communities/manager.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/protocol/communities/manager.go b/protocol/communities/manager.go index 0f1b5a5be..db91b6b10 100644 --- a/protocol/communities/manager.go +++ b/protocol/communities/manager.go @@ -973,6 +973,11 @@ func (rmr reevaluateMemberRole) hasChangedToPrivileged() bool { return rmr.hasChanged() && rmr.old == protobuf.CommunityMember_ROLE_NONE } +func (rmr reevaluateMemberRole) hasChangedPrivilegedRole() bool { + return (rmr.old == protobuf.CommunityMember_ROLE_ADMIN && rmr.new == protobuf.CommunityMember_ROLE_TOKEN_MASTER) || + (rmr.old == protobuf.CommunityMember_ROLE_TOKEN_MASTER && rmr.new == protobuf.CommunityMember_ROLE_ADMIN) +} + type reevaluateMembersResult struct { membersToRemove map[string]struct{} membersRoles map[string]*reevaluateMemberRole @@ -984,7 +989,7 @@ func (rmr *reevaluateMembersResult) newPrivilegedRoles() (map[protobuf.Community result := map[protobuf.CommunityMember_Roles][]*ecdsa.PublicKey{} for memberKey, roles := range rmr.membersRoles { - if roles.hasChangedToPrivileged() { + if roles.hasChangedToPrivileged() || roles.hasChangedPrivilegedRole() { memberPubKey, err := common.HexToPubkey(memberKey) if err != nil { return nil, err