zitadel/internal/repository/instance/policy_mail_text.go

85 lines
1.9 KiB
Go
Raw Normal View History

package instance
2021-02-10 09:48:40 +00:00
import (
"context"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/repository/policy"
2021-02-10 09:48:40 +00:00
)
var (
MailTextAddedEventType = instanceEventTypePrefix + policy.MailTextPolicyAddedEventType
MailTextChangedEventType = instanceEventTypePrefix + policy.MailTextPolicyChangedEventType
2021-02-10 09:48:40 +00:00
)
type MailTextAddedEvent struct {
policy.MailTextAddedEvent
}
func NewMailTextAddedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
2021-02-10 09:48:40 +00:00
mailTextType,
language,
title,
preHeader,
subject,
greeting,
text,
buttonText string,
) *MailTextAddedEvent {
return &MailTextAddedEvent{
MailTextAddedEvent: *policy.NewMailTextAddedEvent(
eventstore.NewBaseEventForPush(ctx, aggregate, MailTextAddedEventType),
2021-02-10 09:48:40 +00:00
mailTextType,
language,
title,
preHeader,
subject,
greeting,
text,
buttonText),
}
}
func MailTextAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
2021-02-10 09:48:40 +00:00
e, err := policy.MailTextAddedEventMapper(event)
if err != nil {
return nil, err
}
return &MailTextAddedEvent{MailTextAddedEvent: *e.(*policy.MailTextAddedEvent)}, nil
}
type MailTextChangedEvent struct {
policy.MailTextChangedEvent
}
func NewMailTextChangedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
2021-02-10 09:48:40 +00:00
mailTextType,
language string,
changes []policy.MailTextChanges,
) (*MailTextChangedEvent, error) {
changedEvent, err := policy.NewMailTextChangedEvent(
eventstore.NewBaseEventForPush(ctx, aggregate, MailTextChangedEventType),
2021-02-10 09:48:40 +00:00
mailTextType,
language,
changes,
)
if err != nil {
return nil, err
}
return &MailTextChangedEvent{MailTextChangedEvent: *changedEvent}, nil
}
func MailTextChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
2021-02-10 09:48:40 +00:00
e, err := policy.MailTextChangedEventMapper(event)
if err != nil {
return nil, err
}
return &MailTextChangedEvent{MailTextChangedEvent: *e.(*policy.MailTextChangedEvent)}, nil
}