fix(community): fix editing a community channel loses the members
This commit is contained in:
parent
e3810148d8
commit
605e3a4ed0
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue