fix: remove rekeying unencrypted communities

This commit is contained in:
Patryk Osmaczko 2023-06-23 12:50:44 +02:00 committed by osmaczko
parent ecf493e6cd
commit 783a6b9153
1 changed files with 5 additions and 7 deletions

View File

@ -1762,7 +1762,6 @@ func (m *Messenger) RemoveUserFromCommunity(id types.HexBytes, pkString string)
return response, nil return response, nil
} }
// TODO
func (m *Messenger) SendKeyExchangeMessage(communityID []byte, pubkeys []*ecdsa.PublicKey, msgType common.CommKeyExMsgType) error { func (m *Messenger) SendKeyExchangeMessage(communityID []byte, pubkeys []*ecdsa.PublicKey, msgType common.CommKeyExMsgType) error {
rawMessage := common.RawMessage{ rawMessage := common.RawMessage{
SkipEncryption: false, SkipEncryption: false,
@ -1796,10 +1795,11 @@ func (m *Messenger) BanUserFromCommunity(request *requests.BanUserFromCommunity)
return nil, err return nil, err
} }
// TODO generate new encryption key if community.Encrypted() {
err = m.SendKeyExchangeMessage(community.ID(), community.GetMemberPubkeys(), common.KeyExMsgRekey) err = m.SendKeyExchangeMessage(community.ID(), community.GetMemberPubkeys(), common.KeyExMsgRekey)
if err != nil { if err != nil {
return nil, err return nil, err
}
} }
response := &MessengerResponse{} response := &MessengerResponse{}
@ -3820,8 +3820,6 @@ func (m *Messenger) UpdateCommunityEncryption(community *communities.Community)
becomeMemberPermissions := community.TokenPermissionsByType(protobuf.CommunityTokenPermission_BECOME_MEMBER) becomeMemberPermissions := community.TokenPermissionsByType(protobuf.CommunityTokenPermission_BECOME_MEMBER)
isEncrypted := len(becomeMemberPermissions) > 0 isEncrypted := len(becomeMemberPermissions) > 0
// Check isEncrypted is different to Community's value
// If not different return
if community.Encrypted() == isEncrypted { if community.Encrypted() == isEncrypted {
return nil, nil return nil, nil
} }