2021-06-10 11:49:10 +00:00
|
|
|
package iam
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"golang.org/x/text/language"
|
|
|
|
|
|
|
|
"github.com/caos/zitadel/internal/eventstore"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/repository"
|
|
|
|
"github.com/caos/zitadel/internal/repository/policy"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2021-07-05 13:10:49 +00:00
|
|
|
CustomTextSetEventType = iamEventTypePrefix + policy.CustomTextSetEventType
|
|
|
|
CustomTextRemovedEventType = iamEventTypePrefix + policy.CustomTextRemovedEventType
|
2021-06-10 11:49:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type CustomTextSetEvent struct {
|
|
|
|
policy.CustomTextSetEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewCustomTextSetEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
template,
|
|
|
|
key,
|
|
|
|
text string,
|
|
|
|
language language.Tag,
|
|
|
|
) *CustomTextSetEvent {
|
|
|
|
return &CustomTextSetEvent{
|
|
|
|
CustomTextSetEvent: *policy.NewCustomTextSetEvent(
|
|
|
|
eventstore.NewBaseEventForPush(ctx, aggregate, CustomTextSetEventType),
|
|
|
|
template,
|
|
|
|
key,
|
|
|
|
text,
|
|
|
|
language),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func CustomTextSetEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
e, err := policy.CustomTextSetEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &CustomTextSetEvent{CustomTextSetEvent: *e.(*policy.CustomTextSetEvent)}, nil
|
|
|
|
}
|
2021-07-05 13:10:49 +00:00
|
|
|
|
|
|
|
type CustomTextRemovedEvent struct {
|
|
|
|
policy.CustomTextRemovedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewCustomTextRemovedEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
template,
|
|
|
|
key string,
|
|
|
|
language language.Tag,
|
|
|
|
) *CustomTextRemovedEvent {
|
|
|
|
return &CustomTextRemovedEvent{
|
|
|
|
CustomTextRemovedEvent: *policy.NewCustomTextRemovedEvent(
|
|
|
|
eventstore.NewBaseEventForPush(ctx, aggregate, CustomTextRemovedEventType),
|
|
|
|
template,
|
|
|
|
key,
|
|
|
|
language),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func CustomTextRemovedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
e, err := policy.CustomTextRemovedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &CustomTextRemovedEvent{CustomTextRemovedEvent: *e.(*policy.CustomTextRemovedEvent)}, nil
|
|
|
|
}
|