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

@ -17,6 +17,11 @@
package grpc
import (
"github.com/ProtonMail/proton-bridge/v3/internal/kb"
"github.com/bradenaw/juniper/xslices"
)
func NewInternetStatusEvent(connected bool) *StreamEvent {
return appEvent(&AppEvent{Event: &AppEvent_InternetStatus{InternetStatus: &InternetStatusEvent{Connected: connected}}})
}
@ -61,6 +66,20 @@ func NewShowMainWindowEvent() *StreamEvent {
return appEvent(&AppEvent{Event: &AppEvent_ShowMainWindow{ShowMainWindow: &ShowMainWindowEvent{}}})
}
func NewRequestKnowledgeBaseSuggestionsEvent(suggestions kb.ArticleList) *StreamEvent {
s := xslices.Map(
suggestions,
func(article kb.Article) *KnowledgeBaseSuggestion {
return &KnowledgeBaseSuggestion{Url: article.URL, Title: article.Title}
},
)
return appEvent(&AppEvent{Event: &AppEvent_KnowledgeBaseSuggestions{
KnowledgeBaseSuggestions: &KnowledgeBaseSuggestionsEvent{
Suggestions: s,
},
}})
}
func NewLoginError(err LoginErrorType, message string) *StreamEvent {
return loginEvent(&LoginEvent{Event: &LoginEvent_Error{Error: &LoginErrorEvent{Type: err, Message: message}}})
}