fix(RequestCommunityInfoFromMailserver): Add useDatabase flag to read/not read community info before requesting mailserver..
Fix #2878
This commit is contained in:
parent
4c29c97591
commit
6e96586bdb
|
@ -145,7 +145,7 @@ func main() {
|
|||
|
||||
messenger := wakuextservice.Messenger()
|
||||
|
||||
community, err := messenger.RequestCommunityInfoFromMailserver(*communityID)
|
||||
community, err := messenger.RequestCommunityInfoFromMailserver(*communityID, true)
|
||||
if err != nil {
|
||||
|
||||
logger.Error("community error", "error", err)
|
||||
|
|
|
@ -1114,7 +1114,7 @@ func (m *Messenger) ImportCommunity(ctx context.Context, key *ecdsa.PrivateKey)
|
|||
|
||||
//request info already stored on mailserver, but its success is not crucial
|
||||
// for import
|
||||
_, _ = m.RequestCommunityInfoFromMailserver(community.IDString())
|
||||
_, _ = m.RequestCommunityInfoFromMailserver(community.IDString(), false)
|
||||
|
||||
// We add ourselves
|
||||
community, err = m.communitiesManager.AddMemberToCommunity(community.ID(), &m.identity.PublicKey)
|
||||
|
@ -1342,8 +1342,10 @@ func (m *Messenger) findCommunityInfoFromDB(communityID string) (*communities.Co
|
|||
}
|
||||
|
||||
// RequestCommunityInfoFromMailserver installs filter for community and requests its details
|
||||
// from mailserver. It waits until it has the community before returning it
|
||||
func (m *Messenger) RequestCommunityInfoFromMailserver(communityID string) (*communities.Community, error) {
|
||||
// from mailserver. It waits until it has the community before returning it.
|
||||
// If useDatabase is true, it searches for community in database and does not request mailserver.
|
||||
func (m *Messenger) RequestCommunityInfoFromMailserver(communityID string, useDatabase bool) (*communities.Community, error) {
|
||||
if useDatabase {
|
||||
community, err := m.findCommunityInfoFromDB(communityID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -1351,6 +1353,7 @@ func (m *Messenger) RequestCommunityInfoFromMailserver(communityID string) (*com
|
|||
if community != nil {
|
||||
return community, nil
|
||||
}
|
||||
}
|
||||
return m.requestCommunityInfoFromMailserver(communityID, true)
|
||||
}
|
||||
|
||||
|
|
|
@ -1032,7 +1032,7 @@ func (api *PublicAPI) EnsVerified(pk, ensName string) error {
|
|||
}
|
||||
|
||||
func (api *PublicAPI) RequestCommunityInfoFromMailserver(communityID string) (*communities.Community, error) {
|
||||
return api.service.messenger.RequestCommunityInfoFromMailserver(communityID)
|
||||
return api.service.messenger.RequestCommunityInfoFromMailserver(communityID, true)
|
||||
}
|
||||
|
||||
func (api *PublicAPI) RequestCommunityInfoFromMailserverAsync(communityID string) error {
|
||||
|
|
|
@ -74,7 +74,7 @@ func (p *PublicAPI) CommunityInfo(communityID types.HexBytes) (json.RawMessage,
|
|||
return nil, ErrNotInitialized
|
||||
}
|
||||
|
||||
community, err := p.service.messenger.RequestCommunityInfoFromMailserver(communityID.String())
|
||||
community, err := p.service.messenger.RequestCommunityInfoFromMailserver(communityID.String(), true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue