2022-03-24 17:21:34 +01:00
|
|
|
package instance
|
2021-07-05 10:36:51 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-01-03 09:19:07 +01:00
|
|
|
|
2023-03-28 21:36:52 +02:00
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
2022-04-27 01:01:45 +02:00
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
|
|
"github.com/zitadel/zitadel/internal/repository/policy"
|
2021-07-05 10:36:51 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2022-03-24 17:21:34 +01:00
|
|
|
PrivacyPolicyAddedEventType = instanceEventTypePrefix + policy.PrivacyPolicyAddedEventType
|
|
|
|
PrivacyPolicyChangedEventType = instanceEventTypePrefix + policy.PrivacyPolicyChangedEventType
|
2021-07-05 10:36:51 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type PrivacyPolicyAddedEvent struct {
|
|
|
|
policy.PrivacyPolicyAddedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPrivacyPolicyAddedEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
tosLink,
|
2022-03-24 14:00:24 +01:00
|
|
|
privacyLink,
|
|
|
|
helpLink string,
|
2023-03-28 21:36:52 +02:00
|
|
|
supportEmail domain.EmailAddress,
|
2021-07-05 10:36:51 +02:00
|
|
|
) *PrivacyPolicyAddedEvent {
|
|
|
|
return &PrivacyPolicyAddedEvent{
|
|
|
|
PrivacyPolicyAddedEvent: *policy.NewPrivacyPolicyAddedEvent(
|
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
PrivacyPolicyAddedEventType),
|
|
|
|
tosLink,
|
2022-03-24 14:00:24 +01:00
|
|
|
privacyLink,
|
2023-03-28 21:36:52 +02:00
|
|
|
helpLink,
|
|
|
|
supportEmail),
|
2021-07-05 10:36:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func PrivacyPolicyAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
2021-07-05 10:36:51 +02:00
|
|
|
e, err := policy.PrivacyPolicyAddedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &PrivacyPolicyAddedEvent{PrivacyPolicyAddedEvent: *e.(*policy.PrivacyPolicyAddedEvent)}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type PrivacyPolicyChangedEvent struct {
|
|
|
|
policy.PrivacyPolicyChangedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPrivacyPolicyChangedEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
changes []policy.PrivacyPolicyChanges,
|
|
|
|
) (*PrivacyPolicyChangedEvent, error) {
|
|
|
|
changedEvent, err := policy.NewPrivacyPolicyChangedEvent(
|
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
PrivacyPolicyChangedEventType),
|
|
|
|
changes,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &PrivacyPolicyChangedEvent{PrivacyPolicyChangedEvent: *changedEvent}, nil
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func PrivacyPolicyChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
2021-07-05 10:36:51 +02:00
|
|
|
e, err := policy.PrivacyPolicyChangedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &PrivacyPolicyChangedEvent{PrivacyPolicyChangedEvent: *e.(*policy.PrivacyPolicyChangedEvent)}, nil
|
|
|
|
}
|