2022-03-24 17:21:34 +01:00
|
|
|
package instance
|
2021-02-10 10:48:40 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-01-03 09:19:07 +01:00
|
|
|
|
2022-04-27 01:01:45 +02:00
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
|
|
"github.com/zitadel/zitadel/internal/repository/policy"
|
2021-02-10 10:48:40 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2022-03-24 17:21:34 +01:00
|
|
|
MailTemplateAddedEventType = instanceEventTypePrefix + policy.MailTemplatePolicyAddedEventType
|
|
|
|
MailTemplateChangedEventType = instanceEventTypePrefix + policy.MailTemplatePolicyChangedEventType
|
2021-02-10 10:48:40 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
type MailTemplateAddedEvent struct {
|
|
|
|
policy.MailTemplateAddedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewMailTemplateAddedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-02-10 10:48:40 +01:00
|
|
|
template []byte,
|
|
|
|
) *MailTemplateAddedEvent {
|
|
|
|
return &MailTemplateAddedEvent{
|
|
|
|
MailTemplateAddedEvent: *policy.NewMailTemplateAddedEvent(
|
2021-02-18 14:48:27 +01:00
|
|
|
eventstore.NewBaseEventForPush(ctx, aggregate, MailTemplateAddedEventType),
|
2021-02-10 10:48:40 +01:00
|
|
|
template),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func MailTemplateAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
2021-02-10 10:48:40 +01:00
|
|
|
e, err := policy.MailTemplateAddedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &MailTemplateAddedEvent{MailTemplateAddedEvent: *e.(*policy.MailTemplateAddedEvent)}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type MailTemplateChangedEvent struct {
|
|
|
|
policy.MailTemplateChangedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewMailTemplateChangedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-02-10 10:48:40 +01:00
|
|
|
changes []policy.MailTemplateChanges,
|
|
|
|
) (*MailTemplateChangedEvent, error) {
|
|
|
|
changedEvent, err := policy.NewMailTemplateChangedEvent(
|
2021-02-18 14:48:27 +01:00
|
|
|
eventstore.NewBaseEventForPush(ctx, aggregate, MailTemplateChangedEventType),
|
2021-02-10 10:48:40 +01:00
|
|
|
changes,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &MailTemplateChangedEvent{MailTemplateChangedEvent: *changedEvent}, nil
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func MailTemplateChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
2021-02-10 10:48:40 +01:00
|
|
|
e, err := policy.MailTemplateChangedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &MailTemplateChangedEvent{MailTemplateChangedEvent: *e.(*policy.MailTemplateChangedEvent)}, nil
|
|
|
|
}
|