2022-03-24 16:21:34 +00:00
|
|
|
package instance
|
2022-03-07 13:22:37 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
|
|
"github.com/zitadel/zitadel/internal/repository/settings"
|
2022-03-07 13:22:37 +00:00
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/eventstore/repository"
|
2022-03-07 13:22:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
logType = ".log"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2022-03-24 16:21:34 +00:00
|
|
|
DebugNotificationProviderLogAddedEventType = instanceEventTypePrefix + settings.DebugNotificationPrefix + logType + settings.DebugNotificationProviderAdded
|
|
|
|
DebugNotificationProviderLogChangedEventType = instanceEventTypePrefix + settings.DebugNotificationPrefix + logType + settings.DebugNotificationProviderChanged
|
|
|
|
DebugNotificationProviderLogEnabledEventType = instanceEventTypePrefix + settings.DebugNotificationPrefix + logType + settings.DebugNotificationProviderEnabled
|
|
|
|
DebugNotificationProviderLogDisabledEventType = instanceEventTypePrefix + settings.DebugNotificationPrefix + logType + settings.DebugNotificationProviderDisabled
|
|
|
|
DebugNotificationProviderLogRemovedEventType = instanceEventTypePrefix + settings.DebugNotificationPrefix + logType + settings.DebugNotificationProviderRemoved
|
2022-03-07 13:22:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type DebugNotificationProviderLogAddedEvent struct {
|
|
|
|
settings.DebugNotificationProviderAddedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewDebugNotificationProviderLogAddedEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
compact bool,
|
|
|
|
) *DebugNotificationProviderLogAddedEvent {
|
|
|
|
return &DebugNotificationProviderLogAddedEvent{
|
|
|
|
DebugNotificationProviderAddedEvent: *settings.NewDebugNotificationProviderAddedEvent(
|
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
DebugNotificationProviderLogAddedEventType),
|
|
|
|
compact),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func DebugNotificationProviderLogAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
|
|
|
e, err := settings.DebugNotificationProviderAddedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &DebugNotificationProviderLogAddedEvent{DebugNotificationProviderAddedEvent: *e.(*settings.DebugNotificationProviderAddedEvent)}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type DebugNotificationProviderLogChangedEvent struct {
|
|
|
|
settings.DebugNotificationProviderChangedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewDebugNotificationProviderLogChangedEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
changes []settings.DebugNotificationProviderChanges,
|
|
|
|
) (*DebugNotificationProviderLogChangedEvent, error) {
|
|
|
|
changedEvent, err := settings.NewDebugNotificationProviderChangedEvent(
|
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
DebugNotificationProviderLogChangedEventType),
|
|
|
|
changes,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &DebugNotificationProviderLogChangedEvent{DebugNotificationProviderChangedEvent: *changedEvent}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func DebugNotificationProviderLogChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
|
|
|
e, err := settings.DebugNotificationProviderChangedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &DebugNotificationProviderLogChangedEvent{DebugNotificationProviderChangedEvent: *e.(*settings.DebugNotificationProviderChangedEvent)}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type DebugNotificationProviderLogRemovedEvent struct {
|
|
|
|
settings.DebugNotificationProviderRemovedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewDebugNotificationProviderLogRemovedEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
) *DebugNotificationProviderLogRemovedEvent {
|
|
|
|
return &DebugNotificationProviderLogRemovedEvent{
|
|
|
|
DebugNotificationProviderRemovedEvent: *settings.NewDebugNotificationProviderRemovedEvent(
|
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
DebugNotificationProviderLogRemovedEventType),
|
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func DebugNotificationProviderLogRemovedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
|
|
|
e, err := settings.DebugNotificationProviderRemovedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &DebugNotificationProviderLogRemovedEvent{DebugNotificationProviderRemovedEvent: *e.(*settings.DebugNotificationProviderRemovedEvent)}, nil
|
|
|
|
}
|