fix(mailservers)_: ToggleUseMailservers should connect/disconnect from active store node

fixes status-im/status-desktop#15032
This commit is contained in:
Andrey Bocharnikov 2024-07-12 19:54:56 +05:00
parent 173bdb590c
commit fe588c7a79
2 changed files with 24 additions and 1 deletions

View File

@ -151,7 +151,18 @@ func (m *Messenger) cycleMailservers() {
m.disconnectActiveMailserver()
}
err := m.findNewMailserver()
useMailserver, err := m.settings.CanUseMailservers()
if err != nil {
m.logger.Error("failed to get use mailservers", zap.Error(err))
return
}
if !useMailserver {
m.logger.Info("Skipping mailserver search due to useMailserver being false")
return
}
err = m.findNewMailserver()
if err != nil {
m.logger.Error("Error getting new mailserver", zap.Error(err))
}

View File

@ -342,3 +342,15 @@ func (s *MessengerStoreNodeCommunitySuite) TestSetStorenodeForCommunity_fetchMes
})
s.Require().NoError(err)
}
func (s *MessengerStoreNodeCommunitySuite) TestToggleUseMailservers() {
// Enable use of mailservers
err := s.owner.ToggleUseMailservers(true)
s.Require().NoError(err)
s.Require().NotNil(s.owner.mailserverCycle.activeMailserver)
// Disable use of mailservers
err = s.owner.ToggleUseMailservers(false)
s.Require().NoError(err)
s.Require().Nil(s.owner.mailserverCycle.activeMailserver)
}