feat(BRIDGE-37): Remote notification support

This commit is contained in:
Atanas Janeshliev
2024-08-29 13:31:37 +02:00
parent ed1b65731a
commit f04350c046
43 changed files with 2350 additions and 1168 deletions

File diff suppressed because it is too large Load Diff

View File

@ -277,6 +277,7 @@ message AppEvent {
KnowledgeBaseSuggestionsEvent knowledgeBaseSuggestions = 12;
RepairStartedEvent repairStarted = 13;
AllUsersLoadedEvent allUsersLoaded = 14;
UserNotificationEvent userNotification = 15;
}
}
@ -545,6 +546,14 @@ message SyncProgressEvent {
int64 remainingMs = 4;
}
message UserNotificationEvent {
string title = 1;
string subtitle = 2;
string body = 3;
string userID = 4;
}
//**********************************************************
// Generic errors
//**********************************************************

View File

@ -18,6 +18,7 @@
package grpc
import (
"github.com/ProtonMail/proton-bridge/v3/internal/events"
"github.com/ProtonMail/proton-bridge/v3/internal/kb"
"github.com/bradenaw/juniper/xslices"
)
@ -249,6 +250,16 @@ func NewAllUsersLoadedEvent() *StreamEvent {
return appEvent(&AppEvent{Event: &AppEvent_AllUsersLoaded{AllUsersLoaded: &AllUsersLoadedEvent{}}})
}
func NewUserNotificationEvent(event events.UserNotification) *StreamEvent {
return appEvent(&AppEvent{Event: &AppEvent_UserNotification{
UserNotification: &UserNotificationEvent{
UserID: event.UserID,
Title: event.Title,
Subtitle: event.Subtitle,
Body: event.Body,
}}})
}
// Event category factory functions.
func appEvent(appEvent *AppEvent) *StreamEvent {

View File

@ -404,6 +404,9 @@ func (s *Service) watchEvents() {
case events.AllUsersLoaded:
_ = s.SendEvent(NewAllUsersLoadedEvent())
case events.UserNotification:
_ = s.SendEvent(NewUserNotificationEvent(event))
}
}
}