fix membership requests on synced devices (#2477)

This commit is contained in:
Parvesh Monu 2022-01-10 17:34:52 +05:30 committed by GitHub
parent fd2f3206d4
commit f1569e4bde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 19 deletions

View File

@ -1 +1 @@
0.92.6 0.92.7

View File

@ -174,6 +174,15 @@ func (m *Messenger) joinCommunity(ctx context.Context, communityID types.HexByte
return nil, err return nil, err
} }
if community.IsAdmin() {
// Init the community filter so we can receive messages on the community
communityFilters, err := m.transport.InitCommunityFilters([]*ecdsa.PrivateKey{community.PrivateKey()})
if err != nil {
return nil, err
}
filters = append(filters, communityFilters...)
}
willSync, err := m.scheduleSyncFilters(filters) willSync, err := m.scheduleSyncFilters(filters)
if err != nil { if err != nil {
logger.Debug("m.scheduleSyncFilters error", zap.Error(err)) logger.Debug("m.scheduleSyncFilters error", zap.Error(err))
@ -990,6 +999,20 @@ func (m *Messenger) handleSyncCommunity(messageState *ReceivedMessageState, sync
return err return err
} }
// associate private key with community if set
if syncCommunity.PrivateKey != nil {
orgPrivKey, err := crypto.ToECDSA(syncCommunity.PrivateKey)
if err != nil {
logger.Debug("crypto.ToECDSA", zap.Error(err))
return err
}
err = m.communitiesManager.SetPrivateKey(syncCommunity.Id, orgPrivKey)
if err != nil {
logger.Debug("m.communitiesManager.SetPrivateKey", zap.Error(err))
return err
}
}
// if we are not waiting for approval, join or leave the community // if we are not waiting for approval, join or leave the community
if !pending { if !pending {
var mr *MessengerResponse var mr *MessengerResponse
@ -1020,23 +1043,5 @@ func (m *Messenger) handleSyncCommunity(messageState *ReceivedMessageState, sync
return err return err
} }
// associate private key with community if set
if syncCommunity.PrivateKey == nil {
logger.Debug("syncCommunity.PrivateKey is nil")
return nil
}
logger.Debug("syncCommunity.PrivateKey is not nil")
orgPrivKey, err := crypto.ToECDSA(syncCommunity.PrivateKey)
if err != nil {
logger.Debug("crypto.ToECDSA", zap.Error(err))
return err
}
err = m.communitiesManager.SetPrivateKey(syncCommunity.Id, orgPrivKey)
if err != nil {
logger.Debug("m.communitiesManager.SetPrivateKey", zap.Error(err))
return err
}
return nil return nil
} }