diff --git a/protocol/communities/community.go b/protocol/communities/community.go index 6fec106bc..84a278f70 100644 --- a/protocol/communities/community.go +++ b/protocol/communities/community.go @@ -621,6 +621,15 @@ func (o *Community) GetMember(pk *ecdsa.PublicKey) *protobuf.CommunityMember { return o.getMember(pk) } +func (o *Community) GetChat(chatID string) (*protobuf.CommunityChat, error) { + chat, ok := o.config.CommunityDescription.Chats[chatID] + if !ok { + return nil, ErrChatNotFound + } + + return chat, nil +} + func (o *Community) getChatMember(pk *ecdsa.PublicKey, chatID string) *protobuf.CommunityMember { if !o.hasMember(pk) { return nil diff --git a/protocol/communities/manager.go b/protocol/communities/manager.go index 5ce0b78c7..666c2d407 100644 --- a/protocol/communities/manager.go +++ b/protocol/communities/manager.go @@ -1469,6 +1469,15 @@ func (m *Manager) EditChat(communityID types.HexBytes, chatID string, chat *prot chatID = strings.TrimPrefix(chatID, communityID.String()) } + oldChat, err := community.GetChat(chatID) + if err != nil { + return nil, nil, err + } + + // We can't edit permissions and members with an Edit, so we set to what we had, otherwise they will be lost + chat.Permissions = oldChat.Permissions + chat.Members = oldChat.Members + changes, err := community.EditChat(chatID, chat) if err != nil { return nil, nil, err