zitadel/internal/repository/instance/custom_text.go
Florian Forster fa9f581d56
chore(v2): move to new org (#3499)
* chore: move to new org

* logging

* fix: org rename caos -> zitadel

Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
2022-04-26 23:01:45 +00:00

106 lines
2.7 KiB
Go

package instance
import (
"context"
"golang.org/x/text/language"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/eventstore/repository"
"github.com/zitadel/zitadel/internal/repository/policy"
)
var (
CustomTextSetEventType = instanceEventTypePrefix + policy.CustomTextSetEventType
CustomTextRemovedEventType = instanceEventTypePrefix + policy.CustomTextRemovedEventType
CustomTextTemplateRemovedEventType = instanceEventTypePrefix + policy.CustomTextTemplateRemovedEventType
)
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.Event, error) {
e, err := policy.CustomTextSetEventMapper(event)
if err != nil {
return nil, err
}
return &CustomTextSetEvent{CustomTextSetEvent: *e.(*policy.CustomTextSetEvent)}, nil
}
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.Event, error) {
e, err := policy.CustomTextRemovedEventMapper(event)
if err != nil {
return nil, err
}
return &CustomTextRemovedEvent{CustomTextRemovedEvent: *e.(*policy.CustomTextRemovedEvent)}, nil
}
type CustomTextTemplateRemovedEvent struct {
policy.CustomTextTemplateRemovedEvent
}
func NewCustomTextTemplateRemovedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
template string,
language language.Tag,
) *CustomTextTemplateRemovedEvent {
return &CustomTextTemplateRemovedEvent{
CustomTextTemplateRemovedEvent: *policy.NewCustomTextTemplateRemovedEvent(
eventstore.NewBaseEventForPush(ctx, aggregate, CustomTextTemplateRemovedEventType),
template,
language,
),
}
}
func CustomTextTemplateRemovedEventMapper(event *repository.Event) (eventstore.Event, error) {
e, err := policy.CustomTextTemplateRemovedEventMapper(event)
if err != nil {
return nil, err
}
return &CustomTextTemplateRemovedEvent{CustomTextTemplateRemovedEvent: *e.(*policy.CustomTextTemplateRemovedEvent)}, nil
}