fix(community): fix member role not being updated

This commit is contained in:
Jonathan Rainville 2024-03-08 14:46:59 -05:00
parent 605e3a4ed0
commit 6f119b9c53
2 changed files with 8 additions and 7 deletions

View File

@ -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:

View File

@ -1056,12 +1056,12 @@ func (m *Manager) ReevaluateMembers(community *Community) (map[protobuf.Communit
if response.ViewAndPostPermissions.Satisfied {
channelRole = protobuf.CommunityMember_CHANNEL_ROLE_POSTER
}
if !isMemberAlreadyInChannel {
// 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)
if err != nil {