2021-03-25 17:26:21 +01:00
|
|
|
package iam
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-01-03 09:19:07 +01:00
|
|
|
|
2021-03-25 17:26:21 +01:00
|
|
|
"github.com/caos/zitadel/internal/eventstore"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/repository"
|
|
|
|
"github.com/caos/zitadel/internal/repository/features"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
FeaturesSetEventType = iamEventTypePrefix + features.FeaturesSetEventType
|
|
|
|
)
|
|
|
|
|
|
|
|
type FeaturesSetEvent struct {
|
|
|
|
features.FeaturesSetEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewFeaturesSetEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
changes []features.FeaturesChanges,
|
|
|
|
) (*FeaturesSetEvent, error) {
|
|
|
|
changedEvent, err := features.NewFeaturesSetEvent(
|
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
FeaturesSetEventType),
|
|
|
|
changes,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &FeaturesSetEvent{FeaturesSetEvent: *changedEvent}, nil
|
|
|
|
}
|
|
|
|
|
2022-01-03 09:19:07 +01:00
|
|
|
func FeaturesSetEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-03-25 17:26:21 +01:00
|
|
|
e, err := features.FeaturesSetEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &FeaturesSetEvent{FeaturesSetEvent: *e.(*features.FeaturesSetEvent)}, nil
|
|
|
|
}
|