From 6f119b9c53eaaa152373c5ad88212bdc4f7b43c6 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Fri, 8 Mar 2024 14:46:59 -0500 Subject: [PATCH] fix(community): fix member role not being updated --- protocol/communities/community.go | 5 +++-- protocol/communities/manager.go | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/protocol/communities/community.go b/protocol/communities/community.go index 84a278f70..f7613beae 100644 --- a/protocol/communities/community.go +++ b/protocol/communities/community.go @@ -1913,8 +1913,9 @@ func (o *Community) CanPost(pk *ecdsa.PublicKey, chatID string, messageType prot if !isChatMember { return false, nil } - isPoster := member.ChannelRole == protobuf.CommunityMember_CHANNEL_ROLE_POSTER - isViewer := member.ChannelRole == protobuf.CommunityMember_CHANNEL_ROLE_VIEWER + + isPoster := member.GetChannelRole() == protobuf.CommunityMember_CHANNEL_ROLE_POSTER + isViewer := member.GetChannelRole() == protobuf.CommunityMember_CHANNEL_ROLE_VIEWER return isPoster || (isViewer && chat.ViewersCanPostReactions), nil default: diff --git a/protocol/communities/manager.go b/protocol/communities/manager.go index 666c2d407..a0c1d039d 100644 --- a/protocol/communities/manager.go +++ b/protocol/communities/manager.go @@ -1056,11 +1056,11 @@ func (m *Manager) ReevaluateMembers(community *Community) (map[protobuf.Communit if response.ViewAndPostPermissions.Satisfied { channelRole = protobuf.CommunityMember_CHANNEL_ROLE_POSTER } - if !isMemberAlreadyInChannel { - _, err := community.AddMemberToChat(channelID, memberPubKey, []protobuf.CommunityMember_Roles{}, channelRole) - if err != nil { - return nil, err - } + + // Add the member back to the chat member list in case the role changed (it replaces the previous values) + _, err := community.AddMemberToChat(channelID, memberPubKey, []protobuf.CommunityMember_Roles{}, channelRole) + if err != nil { + return nil, err } } else if isMemberAlreadyInChannel { _, err := community.RemoveUserFromChat(memberPubKey, channelID)