1
0

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

View File

@ -23,11 +23,13 @@ import (
"fmt"
"net/mail"
"strings"
"time"
"github.com/ProtonMail/gluon/rfc822"
"github.com/ProtonMail/go-proton-api"
"github.com/ProtonMail/gopenpgp/v2/crypto"
"github.com/ProtonMail/proton-bridge/v3/internal/bridge"
"github.com/ProtonMail/proton-bridge/v3/internal/services/notifications"
"github.com/ProtonMail/proton-bridge/v3/internal/vault"
"github.com/ProtonMail/proton-bridge/v3/pkg/algo"
"github.com/bradenaw/juniper/iterator"
@ -690,3 +692,24 @@ func matchSettings(have proton.MailSettings, want MailSettings) error {
return nil
}
func (s *scenario) userRemoteNotificationMetricTest(username string, metricName string) error {
var metricToTest proton.ObservabilityMetric
switch strings.ToLower(metricName) {
case "processed":
metricToTest = notifications.GenerateProcessedMetric(1)
case "received":
metricToTest = notifications.GenerateReceivedMetric(1)
default:
return fmt.Errorf("invalid metric name specified")
}
// Account for endpoint throttle
time.Sleep(time.Second * 5)
return s.t.withClientPass(context.Background(), username, s.t.getUserByName(username).userPass, func(ctx context.Context, c *proton.Client) error {
batch := proton.ObservabilityBatch{Metrics: []proton.ObservabilityMetric{metricToTest}}
err := c.SendObservabilityBatch(ctx, batch)
return err
})
}