mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-11 13:16:53 +00:00
feat(GODT-2799): SMTP service interacts directly with Server Manager
Bridge no longer needs to manually add and remove accounts from the service.
This commit is contained in:
@ -22,23 +22,12 @@ import (
|
||||
"crypto/tls"
|
||||
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/identifier"
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/user"
|
||||
)
|
||||
|
||||
func (bridge *Bridge) restartSMTP(ctx context.Context) error {
|
||||
return bridge.serverManager.RestartSMTP(ctx)
|
||||
}
|
||||
|
||||
// addSMTPUser connects the given user to the smtp server.
|
||||
func (bridge *Bridge) addSMTPUser(ctx context.Context, user *user.User) error {
|
||||
return bridge.serverManager.AddSMTPAccount(ctx, user.GetSMTPService())
|
||||
}
|
||||
|
||||
// removeSMTPUser disconnects the given user from the smtp server.
|
||||
func (bridge *Bridge) removeSMTPUser(ctx context.Context, user *user.User) error {
|
||||
return bridge.serverManager.RemoveSMTPAccount(ctx, user.GetSMTPService())
|
||||
}
|
||||
|
||||
type bridgeSMTPSettings struct {
|
||||
b *Bridge
|
||||
}
|
||||
|
||||
@ -522,16 +522,13 @@ func (bridge *Bridge) addUserWithVault(
|
||||
statsPath,
|
||||
bridge,
|
||||
bridge.serverManager,
|
||||
bridge.serverManager,
|
||||
&bridgeEventSubscription{b: bridge},
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create user: %w", err)
|
||||
}
|
||||
|
||||
if err := bridge.addSMTPUser(ctx, user); err != nil {
|
||||
return fmt.Errorf("failed to add SMTP user: %w", err)
|
||||
}
|
||||
|
||||
// Handle events coming from the user before forwarding them to the bridge.
|
||||
// For example, if the user's addresses change, we need to update them in gluon.
|
||||
bridge.tasks.Once(func(ctx context.Context) {
|
||||
@ -593,10 +590,6 @@ func (bridge *Bridge) logoutUser(ctx context.Context, user *user.User, withAPI,
|
||||
"withData": withData,
|
||||
}).Debug("Logging out user")
|
||||
|
||||
if err := bridge.removeSMTPUser(ctx, user); err != nil {
|
||||
logrus.WithError(err).Error("Failed to remove SMTP user")
|
||||
}
|
||||
|
||||
if err := user.Logout(ctx, withAPI); err != nil {
|
||||
logrus.WithError(err).Error("Failed to logout user")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user