feat(GODT-3121): added gRPC call and event for KB suggestions.

This commit is contained in:
Xavier Michelon
2023-11-27 18:59:37 +01:00
parent 51722eb1a4
commit 3070912416
12 changed files with 1372 additions and 1068 deletions

View File

@ -30,6 +30,7 @@ import (
"github.com/ProtonMail/proton-bridge/v3/internal/constants"
"github.com/ProtonMail/proton-bridge/v3/internal/events"
"github.com/ProtonMail/proton-bridge/v3/internal/frontend/theme"
"github.com/ProtonMail/proton-bridge/v3/internal/kb"
"github.com/ProtonMail/proton-bridge/v3/internal/safe"
"github.com/ProtonMail/proton-bridge/v3/internal/service"
"github.com/ProtonMail/proton-bridge/v3/internal/updater"
@ -375,6 +376,23 @@ func (s *Service) SetMainExecutable(_ context.Context, exe *wrapperspb.StringVal
return &emptypb.Empty{}, nil
}
func (s *Service) RequestKnowledgeBaseSuggestions(_ context.Context, userInput *wrapperspb.StringValue) (*emptypb.Empty, error) {
s.log.Debug("RequestKnowledgeBaseSuggestions")
go func() {
defer async.HandlePanic(s.panicHandler)
articles, err := s.bridge.GetKnowledgeBaseSuggestions(userInput.Value)
if err != nil {
s.log.WithError(err).Error("Could not retrieve KB article suggestions")
articles = kb.ArticleList{}
}
_ = s.SendEvent(NewRequestKnowledgeBaseSuggestionsEvent(articles))
}()
return &emptypb.Empty{}, nil
}
func (s *Service) Login(_ context.Context, login *LoginRequest) (*emptypb.Empty, error) {
s.log.WithField("username", login.Username).Debug("Login")