feat: improve milestone format (#6150)

* feat: milestone format

* feat: push external domain

* cleanup

* Revert "remove prerelease"

This reverts commit 7417fdbeb3.

* fix branch

* remove prerelease
This commit is contained in:
Elio Bischof
2023-07-06 19:31:08 +02:00
committed by GitHub
parent a36818c222
commit 9b768003b7
5 changed files with 23 additions and 5 deletions

View File

@@ -214,7 +214,7 @@ func startZitadel(config *Config, masterKey string, server chan<- *Server) error
}
actions.SetLogstoreService(actionsLogstoreSvc)
notification.Start(ctx, config.Projections.Customizations["notifications"], config.Projections.Customizations["notificationsquotas"], config.Projections.Customizations["telemetry"], *config.Telemetry, config.ExternalPort, config.ExternalSecure, commands, queries, eventstoreClient, assets.AssetAPIFromDomain(config.ExternalSecure, config.ExternalPort), config.SystemDefaults.Notifications.FileSystemPath, keys.User, keys.SMTP, keys.SMS)
notification.Start(ctx, config.Projections.Customizations["notifications"], config.Projections.Customizations["notificationsquotas"], config.Projections.Customizations["telemetry"], *config.Telemetry, config.ExternalDomain, config.ExternalPort, config.ExternalSecure, commands, queries, eventstoreClient, assets.AssetAPIFromDomain(config.ExternalSecure, config.ExternalPort), config.SystemDefaults.Notifications.FileSystemPath, keys.User, keys.SMTP, keys.SMS)
router := mux.NewRouter()
tlsConfig, err := config.TLS.Config()

View File

@@ -12,6 +12,7 @@ import (
type NotificationQueries struct {
*query.Queries
es *eventstore.Eventstore
externalDomain string
externalPort uint16
externalSecure bool
fileSystemPath string
@@ -24,6 +25,7 @@ type NotificationQueries struct {
func NewNotificationQueries(
baseQueries *query.Queries,
es *eventstore.Eventstore,
externalDomain string,
externalPort uint16,
externalSecure bool,
fileSystemPath string,
@@ -35,6 +37,7 @@ func NewNotificationQueries(
return &NotificationQueries{
Queries: baseQueries,
es: es,
externalDomain: externalDomain,
externalPort: externalPort,
externalSecure: externalSecure,
fileSystemPath: fileSystemPath,

View File

@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/http"
"time"
"github.com/zitadel/logging"
@@ -128,6 +129,7 @@ func (t *telemetryPusher) pushMilestone(ctx context.Context, event *pseudo.Sched
if alreadyHandled {
return nil
}
for _, endpoint := range t.cfg.Endpoints {
if err := types.SendJSON(
ctx,
@@ -138,7 +140,19 @@ func (t *telemetryPusher) pushMilestone(ctx context.Context, event *pseudo.Sched
},
t.queries.GetFileSystemProvider,
t.queries.GetLogProvider,
ms,
&struct {
InstanceID string `json:"instanceId"`
ExternalDomain string `json:"externalDomain"`
PrimaryDomain string `json:"primaryDomain"`
Type milestone.Type `json:"type"`
ReachedDate time.Time `json:"reached"`
}{
InstanceID: ms.InstanceID,
ExternalDomain: t.queries.externalDomain,
PrimaryDomain: ms.PrimaryDomain,
Type: ms.Type,
ReachedDate: ms.ReachedDate,
},
event,
t.metricSuccessfulDeliveriesJSON,
t.metricFailedDeliveriesJSON,

View File

@@ -73,8 +73,8 @@ func awaitMilestone(t *testing.T, bodies chan []byte, primaryDomain, expectMiles
}
t.Log("received milestone", plain.String())
milestone := struct {
Type string
PrimaryDomain string
Type string `json:"type"`
PrimaryDomain string `json:"primaryDomain"`
}{}
if err := json.Unmarshal(body, &milestone); err != nil {
t.Error(err)

View File

@@ -31,6 +31,7 @@ func Start(
quotaHandlerCustomConfig projection.CustomConfig,
telemetryHandlerCustomConfig projection.CustomConfig,
telemetryCfg handlers.TelemetryPusherConfig,
externalDomain string,
externalPort uint16,
externalSecure bool,
commands *command.Commands,
@@ -56,7 +57,7 @@ func Start(
logging.WithFields("metric", metricSuccessfulDeliveriesJSON).OnError(err).Panic("unable to register counter")
err = metrics.RegisterCounter(metricFailedDeliveriesJSON, "Failed JSON message deliveries")
logging.WithFields("metric", metricFailedDeliveriesJSON).OnError(err).Panic("unable to register counter")
q := handlers.NewNotificationQueries(queries, es, externalPort, externalSecure, fileSystemPath, userEncryption, smtpEncryption, smsEncryption, statikFS)
q := handlers.NewNotificationQueries(queries, es, externalDomain, externalPort, externalSecure, fileSystemPath, userEncryption, smtpEncryption, smsEncryption, statikFS)
handlers.NewUserNotifier(
ctx,
projection.ApplyCustomConfig(userHandlerCustomConfig),