From 1d64cc6129a7232db959e7ab2716ae878c15789d Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 3 Jul 2023 12:25:58 +0200 Subject: [PATCH] review --- internal/query/projection/milestones.go | 10 +++++++++- internal/query/user.go | 1 - internal/repository/pseudo/events.go | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/query/projection/milestones.go b/internal/query/projection/milestones.go index 0866354dd6..eed288c7ac 100644 --- a/internal/query/projection/milestones.go +++ b/internal/query/projection/milestones.go @@ -2,6 +2,8 @@ package projection import ( "context" + "strconv" + "strings" "github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore/handler" @@ -286,5 +288,11 @@ func (p *milestoneProjection) reduceAppConfigAdded(event eventstore.Event, clien } func (p *milestoneProjection) isSystemEvent(event eventstore.Event) bool { - return event.EditorUser() == "" || event.EditorService() == "" || event.EditorService() == "SYSTEM" + if _, err := strconv.Atoi(event.EditorUser()); err == nil { + return false + } + lowerEditorService := strings.ToLower(event.EditorService()) + return lowerEditorService == "" || + lowerEditorService == "system" || + lowerEditorService == "system-api" } diff --git a/internal/query/user.go b/internal/query/user.go index 7923e5da53..1550a4678b 100644 --- a/internal/query/user.go +++ b/internal/query/user.go @@ -338,7 +338,6 @@ func (q *Queries) GetUserByID(ctx context.Context, shouldTriggerBulk bool, userI defer func() { span.EndWithError(err) }() if shouldTriggerBulk { - // TODO: Why are these errors not handled? projection.UserProjection.Trigger(ctx) projection.LoginNameProjection.Trigger(ctx) } diff --git a/internal/repository/pseudo/events.go b/internal/repository/pseudo/events.go index c1e5900fa1..0baaa9368f 100644 --- a/internal/repository/pseudo/events.go +++ b/internal/repository/pseudo/events.go @@ -1,3 +1,4 @@ +// Package pseudo contains virtual events, that are not stored in the eventstore. package pseudo import ( @@ -20,6 +21,8 @@ type ScheduledEvent struct { InstanceIDs []string `json:"-"` } +// NewScheduledEvent returns an event that can be processed by event handlers like any other event. +// It receives the current timestamp and an ID list of instances that are active and should be processed. func NewScheduledEvent( ctx context.Context, timestamp time.Time,