mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 19:14:23 +00:00
00fec8830a
* fix: push events instead of aggregates * fix: tests * try without aggregate methods and with aggregate methods * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: client secret * fix: query eventtypes * fix: query eventtypes * fix: eventstore index * fix: index * fix: merge new eventstore * fix: remove unnecessary todos * fix: remove unnecessary todos Co-authored-by: Fabiennne <fabienne.gerschwiler@gmail.com>
93 lines
2.6 KiB
Go
93 lines
2.6 KiB
Go
package org
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
|
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
|
"github.com/caos/zitadel/internal/v2/repository/policy"
|
|
)
|
|
|
|
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,
|
|
template []byte,
|
|
) *MailTemplateAddedEvent {
|
|
return &MailTemplateAddedEvent{
|
|
MailTemplateAddedEvent: *policy.NewMailTemplateAddedEvent(
|
|
eventstore.NewBaseEventForPush(ctx, aggregate, MailTemplateAddedEventType),
|
|
template),
|
|
}
|
|
}
|
|
|
|
func MailTemplateAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
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,
|
|
changes []policy.MailTemplateChanges,
|
|
) (*MailTemplateChangedEvent, error) {
|
|
changedEvent, err := policy.NewMailTemplateChangedEvent(
|
|
eventstore.NewBaseEventForPush(ctx, aggregate, MailTemplateChangedEventType),
|
|
changes,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &MailTemplateChangedEvent{MailTemplateChangedEvent: *changedEvent}, nil
|
|
}
|
|
|
|
func MailTemplateChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
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,
|
|
) *MailTemplateRemovedEvent {
|
|
return &MailTemplateRemovedEvent{
|
|
MailTemplateRemovedEvent: *policy.NewMailTemplateRemovedEvent(
|
|
eventstore.NewBaseEventForPush(ctx, aggregate, MailTemplateRemovedEventType),
|
|
),
|
|
}
|
|
}
|
|
|
|
func MailTemplateRemovedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e, err := policy.MailTemplateRemovedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &MailTemplateRemovedEvent{MailTemplateRemovedEvent: *e.(*policy.MailTemplateRemovedEvent)}, nil
|
|
}
|