2022-03-24 16:21:34 +00:00
|
|
|
package instance
|
2021-03-25 16:26:21 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-01-03 08:19:07 +00:00
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore/repository"
|
|
|
|
"github.com/zitadel/zitadel/internal/repository/features"
|
2021-03-25 16:26:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2022-03-24 16:21:34 +00:00
|
|
|
FeaturesSetEventType = instanceEventTypePrefix + features.FeaturesSetEventType
|
2021-03-25 16:26:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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 08:19:07 +00:00
|
|
|
func FeaturesSetEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-03-25 16:26:21 +00:00
|
|
|
e, err := features.FeaturesSetEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &FeaturesSetEvent{FeaturesSetEvent: *e.(*features.FeaturesSetEvent)}, nil
|
|
|
|
}
|