Other(refactor): Move UserAgent out of frontend

This commit is contained in:
James Houlahan
2022-08-18 16:15:19 +02:00
committed by Jakub
parent 1a8e4c953d
commit 4c52a12507
9 changed files with 23 additions and 12 deletions

View File

@ -21,7 +21,6 @@ package frontend
import (
"github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/ProtonMail/proton-bridge/v2/internal/config/useragent"
"github.com/ProtonMail/proton-bridge/v2/internal/frontend/cli"
"github.com/ProtonMail/proton-bridge/v2/internal/frontend/grpc"
"github.com/ProtonMail/proton-bridge/v2/internal/frontend/types"
@ -46,7 +45,6 @@ func New(
settings *settings.Settings,
eventListener listener.Listener,
updater types.Updater,
userAgent *useragent.UserAgent,
bridge *bridge.Bridge,
noEncConfirmator types.NoEncConfirmator,
restarter types.Restarter,
@ -60,7 +58,6 @@ func New(
settings,
eventListener,
updater,
userAgent,
bridgeWrap,
noEncConfirmator,
restarter,

View File

@ -28,7 +28,6 @@ import (
"github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/ProtonMail/proton-bridge/v2/internal/config/useragent"
"github.com/ProtonMail/proton-bridge/v2/internal/events"
"github.com/ProtonMail/proton-bridge/v2/internal/frontend/types"
"github.com/ProtonMail/proton-bridge/v2/internal/updater"
@ -55,7 +54,6 @@ type Service struct { // nolint:structcheck
eventListener listener.Listener
updater types.Updater
updateCheckMutex sync.Mutex
userAgent *useragent.UserAgent
bridge types.Bridger
restarter types.Restarter
showOnStartup bool
@ -76,7 +74,6 @@ func NewService(
settings *settings.Settings,
eventListener listener.Listener,
updater types.Updater,
userAgent *useragent.UserAgent,
bridge types.Bridger,
_ types.NoEncConfirmator,
restarter types.Restarter,
@ -88,7 +85,6 @@ func NewService(
settings: settings,
eventListener: eventListener,
updater: updater,
userAgent: userAgent,
bridge: bridge,
restarter: restarter,
showOnStartup: showOnStartup,

View File

@ -258,7 +258,7 @@ func (s *Service) ColorSchemeName(context.Context, *emptypb.Empty) (*wrapperspb.
func (s *Service) CurrentEmailClient(context.Context, *emptypb.Empty) (*wrapperspb.StringValue, error) {
s.log.Info("CurrentEmailClient")
return wrapperspb.String(s.userAgent.String()), nil
return wrapperspb.String(s.bridge.GetCurrentUserAgent()), nil
}
func (s *Service) ReportBug(_ context.Context, report *ReportBugRequest) (*emptypb.Empty, error) {

View File

@ -34,7 +34,7 @@ func (s *Service) StartEventStream(request *EventStreamRequest, server Bridge_St
return status.Errorf(codes.AlreadyExists, "the service is already streaming") // TO-DO GODT-1667 decide if we want to kill the existing stream.
}
s.userAgent.SetPlatform(request.ClientPlatform)
s.bridge.SetCurrentPlatform(request.ClientPlatform)
s.eventStreamCh = make(chan *StreamEvent)
s.eventStreamDoneCh = make(chan struct{})

View File

@ -85,6 +85,9 @@ type Bridger interface {
GetLicenseFilePath() string
GetDependencyLicensesLink() string
GetCurrentUserAgent() string
SetCurrentPlatform(string)
// -- old --
ReportBug(osType, osVersion, description, accountName, address, emailClient string, attachLogs bool) error