mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-11 05:06:51 +00:00
feat(GODT-2585): Only Start IMAP/SMTP once one user is loaded
Update ServerManager to follow the new expected behavior. The servers will only be started when one user is active. If all users are logged out or removed from the system, the servers will stop. If the network goes down, the servers will stop and resume once network has been restored.
This commit is contained in:
@ -28,6 +28,7 @@ import (
|
||||
"github.com/ProtonMail/go-proton-api"
|
||||
"github.com/ProtonMail/gopenpgp/v2/crypto"
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/bridge"
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/events"
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/vault"
|
||||
"github.com/ProtonMail/proton-bridge/v3/pkg/algo"
|
||||
"github.com/bradenaw/juniper/iterator"
|
||||
@ -331,10 +332,20 @@ func (s *scenario) drafAtIndexWasMovedToTrashForAddressOfAccount(draftIndex int,
|
||||
}
|
||||
|
||||
func (s *scenario) userLogsInWithUsernameAndPassword(username, password string) error {
|
||||
evtCh, cancel := s.t.bridge.GetEvents(events.SMTPServerReady{})
|
||||
defer cancel()
|
||||
|
||||
userID, err := s.t.bridge.LoginFull(context.Background(), username, []byte(password), nil, nil)
|
||||
if err != nil {
|
||||
s.t.pushError(err)
|
||||
} else {
|
||||
// We need to wait for server to be up or we won't be able to connect. It should only happen once to avoid
|
||||
// blocking on multiple Logins.
|
||||
if !s.t.imapServerStarted {
|
||||
<-evtCh
|
||||
s.t.imapServerStarted = true
|
||||
}
|
||||
|
||||
if userID != s.t.getUserByName(username).getUserID() {
|
||||
return errors.New("user ID mismatch")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user