fix: setup owner as CommunityDescription signer after minting community owner token (#4168)

This commit is contained in:
Mykhailo Prakhov 2023-10-19 13:03:41 +02:00 committed by GitHub
parent 9b44cf65ed
commit 74c13fd363
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

View File

@ -4701,6 +4701,10 @@ func (m *Manager) AddCommunityToken(token *community_token.CommunityToken) (*Com
if err != nil {
return nil, err
}
if token.PrivilegesLevel == community_token.OwnerLevel {
m.promoteSelfToControlNode(community)
}
}
return community, m.saveAndPublish(community)
@ -5027,21 +5031,21 @@ func (m *Manager) PromoteSelfToControlNode(communityID types.HexBytes) (*Communi
if err != nil {
return nil, err
}
if community == nil {
return nil, ErrOrgNotFound
}
m.promoteSelfToControlNode(community)
return community, m.saveAndPublish(community)
}
func (m *Manager) promoteSelfToControlNode(community *Community) {
community.setPrivateKey(m.identity)
if !community.ControlNode().Equal(&m.identity.PublicKey) {
community.setControlNode(&m.identity.PublicKey)
}
err = m.saveAndPublish(community)
if err != nil {
return nil, err
}
return community, nil
}
func (m *Manager) shareRequestsToJoinWithNewPrivilegedMembers(community *Community, newPrivilegedMembers map[protobuf.CommunityMember_Roles][]*ecdsa.PublicKey) error {

View File

@ -2296,6 +2296,11 @@ func (m *Messenger) handleChatMessage(state *ReceivedMessageState, forceSeen boo
if err != nil {
return err
}
if communityResponse == nil {
return nil
}
community := communityResponse.Community
receivedMessage.CommunityID = community.IDString()