mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 11:34:26 +00:00
84 lines
1.9 KiB
Go
84 lines
1.9 KiB
Go
|
package iam
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
||
|
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||
|
"github.com/caos/zitadel/internal/v2/domain"
|
||
|
"github.com/caos/zitadel/internal/v2/repository/policy"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
MailTextAddedEventType = iamEventTypePrefix + policy.MailTextPolicyAddedEventType
|
||
|
MailTextChangedEventType = iamEventTypePrefix + policy.MailTextPolicyChangedEventType
|
||
|
)
|
||
|
|
||
|
type MailTextAddedEvent struct {
|
||
|
policy.MailTextAddedEvent
|
||
|
}
|
||
|
|
||
|
func NewMailTextAddedEvent(
|
||
|
ctx context.Context,
|
||
|
mailTextType,
|
||
|
language,
|
||
|
title,
|
||
|
preHeader,
|
||
|
subject,
|
||
|
greeting,
|
||
|
text,
|
||
|
buttonText string,
|
||
|
) *MailTextAddedEvent {
|
||
|
return &MailTextAddedEvent{
|
||
|
MailTextAddedEvent: *policy.NewMailTextAddedEvent(
|
||
|
eventstore.NewBaseEventForPushWithResourceOwner(ctx, MailTextAddedEventType, domain.IAMID),
|
||
|
mailTextType,
|
||
|
language,
|
||
|
title,
|
||
|
preHeader,
|
||
|
subject,
|
||
|
greeting,
|
||
|
text,
|
||
|
buttonText),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func MailTextAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||
|
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,
|
||
|
mailTextType,
|
||
|
language string,
|
||
|
changes []policy.MailTextChanges,
|
||
|
) (*MailTextChangedEvent, error) {
|
||
|
changedEvent, err := policy.NewMailTextChangedEvent(
|
||
|
eventstore.NewBaseEventForPush(ctx, MailTextChangedEventType),
|
||
|
mailTextType,
|
||
|
language,
|
||
|
changes,
|
||
|
)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return &MailTextChangedEvent{MailTextChangedEvent: *changedEvent}, nil
|
||
|
}
|
||
|
|
||
|
func MailTextChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||
|
e, err := policy.MailTextChangedEventMapper(event)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
return &MailTextChangedEvent{MailTextChangedEvent: *e.(*policy.MailTextChangedEvent)}, nil
|
||
|
}
|