mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 23:56:56 +00:00
feat(GODT-3121): added gRPC call and event for KB suggestions.
This commit is contained in:
@ -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}}})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user