zitadel/internal/repository/org/policy_mail_template.go

92 lines
2.5 KiB
Go
Raw Normal View History

2021-02-10 10:48:40 +01:00
package org
import (
"context"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/repository/policy"
2021-02-10 10:48:40 +01:00
)
var (
MailTemplateAddedEventType = orgEventTypePrefix + policy.MailTemplatePolicyAddedEventType
MailTemplateChangedEventType = orgEventTypePrefix + policy.MailTemplatePolicyChangedEventType
MailTemplateRemovedEventType = orgEventTypePrefix + policy.MailTemplatePolicyRemovedEventType
)
type MailTemplateAddedEvent struct {
policy.MailTemplateAddedEvent
}
func NewMailTemplateAddedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
2021-02-10 10:48:40 +01:00
template []byte,
) *MailTemplateAddedEvent {
return &MailTemplateAddedEvent{
MailTemplateAddedEvent: *policy.NewMailTemplateAddedEvent(
eventstore.NewBaseEventForPush(ctx, aggregate, MailTemplateAddedEventType),
2021-02-10 10:48:40 +01:00
template),
}
}
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,
aggregate *eventstore.Aggregate,
2021-02-10 10:48:40 +01:00
changes []policy.MailTemplateChanges,
) (*MailTemplateChangedEvent, error) {
changedEvent, err := policy.NewMailTemplateChangedEvent(
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
}
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
}
type MailTemplateRemovedEvent struct {
policy.MailTemplateRemovedEvent
}
func NewMailTemplateRemovedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
2021-02-10 10:48:40 +01:00
) *MailTemplateRemovedEvent {
return &MailTemplateRemovedEvent{
MailTemplateRemovedEvent: *policy.NewMailTemplateRemovedEvent(
eventstore.NewBaseEventForPush(ctx, aggregate, MailTemplateRemovedEventType),
2021-02-10 10:48:40 +01:00
),
}
}
func MailTemplateRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
2021-02-10 10:48:40 +01:00
e, err := policy.MailTemplateRemovedEventMapper(event)
if err != nil {
return nil, err
}
return &MailTemplateRemovedEvent{MailTemplateRemovedEvent: *e.(*policy.MailTemplateRemovedEvent)}, nil
}