fix scheduled pseudo event projection

This commit is contained in:
Elio Bischof
2023-06-28 17:43:19 +02:00
parent ec8b587ba6
commit 2b8dac40de
9 changed files with 42 additions and 29 deletions

View File

@@ -1,6 +1,9 @@
package milestone
import (
"context"
"github.com/zitadel/zitadel/internal/api/authz"
"github.com/zitadel/zitadel/internal/eventstore"
)
@@ -13,13 +16,14 @@ type Aggregate struct {
eventstore.Aggregate
}
func NewAggregate(id, resourceOwner, instanceID string) *Aggregate {
func NewAggregate(ctx context.Context, id string) *Aggregate {
instanceID := authz.GetInstance(ctx).InstanceID()
return &Aggregate{
Aggregate: eventstore.Aggregate{
Type: AggregateType,
Version: AggregateVersion,
ID: id,
ResourceOwner: resourceOwner,
ResourceOwner: instanceID,
InstanceID: instanceID,
},
}

View File

@@ -16,13 +16,15 @@ var _ eventstore.Event = (*ScheduledEvent)(nil)
type ScheduledEvent struct {
*eventstore.BaseEvent `json:"-"`
Timestamp time.Time `json:"-"`
InstanceIDs []string `json:"-"`
Timestamp time.Time `json:"timestamp"`
InstanceIDs []string `json:"instanceIDs"`
TriggeringEvent eventstore.Event `json:"triggeringEvent"`
}
func NewScheduledEvent(
ctx context.Context,
timestamp time.Time,
triggeringEvent eventstore.Event,
instanceIDs ...string,
) *ScheduledEvent {
return &ScheduledEvent{
@@ -31,7 +33,8 @@ func NewScheduledEvent(
&NewAggregate().Aggregate,
ScheduledEventType,
),
Timestamp: timestamp,
InstanceIDs: instanceIDs,
Timestamp: timestamp,
InstanceIDs: instanceIDs,
TriggeringEvent: triggeringEvent,
}
}