2021-02-10 09:48:40 +00:00
|
|
|
package org
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-01-03 08:19:07 +00:00
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
2021-02-10 09:48:40 +00:00
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/eventstore/repository"
|
|
|
|
"github.com/zitadel/zitadel/internal/repository/policy"
|
2021-02-10 09:48:40 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
MailTextAddedEventType = orgEventTypePrefix + policy.MailTextPolicyAddedEventType
|
|
|
|
MailTextChangedEventType = orgEventTypePrefix + policy.MailTextPolicyChangedEventType
|
|
|
|
MailTextRemovedEventType = orgEventTypePrefix + policy.MailTextPolicyRemovedEventType
|
|
|
|
)
|
|
|
|
|
|
|
|
type MailTextAddedEvent struct {
|
|
|
|
policy.MailTextAddedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewMailTextAddedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
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(
|
2021-02-18 13:48:27 +00:00
|
|
|
eventstore.NewBaseEventForPush(ctx, aggregate, MailTextAddedEventType),
|
2021-02-10 09:48:40 +00:00
|
|
|
mailTextType,
|
|
|
|
language,
|
|
|
|
title,
|
|
|
|
preHeader,
|
|
|
|
subject,
|
|
|
|
greeting,
|
|
|
|
text,
|
|
|
|
buttonText),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 08:19:07 +00:00
|
|
|
func MailTextAddedEventMapper(event *repository.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,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-02-10 09:48:40 +00:00
|
|
|
mailTextType,
|
|
|
|
language string,
|
|
|
|
changes []policy.MailTextChanges,
|
|
|
|
) (*MailTextChangedEvent, error) {
|
|
|
|
changedEvent, err := policy.NewMailTextChangedEvent(
|
2021-02-18 13:48:27 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2022-01-03 08:19:07 +00:00
|
|
|
func MailTextChangedEventMapper(event *repository.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
|
|
|
|
}
|
|
|
|
|
|
|
|
type MailTextRemovedEvent struct {
|
|
|
|
policy.MailTextRemovedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewMailTextRemovedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-02-10 09:48:40 +00:00
|
|
|
mailTextType,
|
|
|
|
language string,
|
|
|
|
) *MailTextRemovedEvent {
|
|
|
|
return &MailTextRemovedEvent{
|
|
|
|
MailTextRemovedEvent: *policy.NewMailTextRemovedEvent(
|
2021-02-18 13:48:27 +00:00
|
|
|
eventstore.NewBaseEventForPush(ctx, aggregate, MailTextRemovedEventType),
|
2021-02-10 09:48:40 +00:00
|
|
|
mailTextType,
|
|
|
|
language,
|
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 08:19:07 +00:00
|
|
|
func MailTextRemovedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-02-10 09:48:40 +00:00
|
|
|
e, err := policy.MailTextRemovedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &MailTextRemovedEvent{MailTextRemovedEvent: *e.(*policy.MailTextRemovedEvent)}, nil
|
|
|
|
}
|