2022-03-24 16:21:34 +00:00
|
|
|
package instance
|
2021-07-05 08:36:51 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-01-03 08:19:07 +00:00
|
|
|
|
2023-03-28 19:36:52 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
|
|
"github.com/zitadel/zitadel/internal/repository/policy"
|
2021-07-05 08:36:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2022-03-24 16:21:34 +00:00
|
|
|
PrivacyPolicyAddedEventType = instanceEventTypePrefix + policy.PrivacyPolicyAddedEventType
|
|
|
|
PrivacyPolicyChangedEventType = instanceEventTypePrefix + policy.PrivacyPolicyChangedEventType
|
2021-07-05 08:36:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type PrivacyPolicyAddedEvent struct {
|
|
|
|
policy.PrivacyPolicyAddedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPrivacyPolicyAddedEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
tosLink,
|
2022-03-24 13:00:24 +00:00
|
|
|
privacyLink,
|
|
|
|
helpLink string,
|
2023-03-28 19:36:52 +00:00
|
|
|
supportEmail domain.EmailAddress,
|
2024-05-13 14:01:50 +00:00
|
|
|
docsLink, customLink, customLinkText string,
|
2021-07-05 08:36:51 +00:00
|
|
|
) *PrivacyPolicyAddedEvent {
|
|
|
|
return &PrivacyPolicyAddedEvent{
|
|
|
|
PrivacyPolicyAddedEvent: *policy.NewPrivacyPolicyAddedEvent(
|
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
PrivacyPolicyAddedEventType),
|
|
|
|
tosLink,
|
2022-03-24 13:00:24 +00:00
|
|
|
privacyLink,
|
2023-03-28 19:36:52 +00:00
|
|
|
helpLink,
|
2024-05-13 14:01:50 +00:00
|
|
|
supportEmail,
|
|
|
|
docsLink,
|
|
|
|
customLink,
|
|
|
|
customLinkText),
|
2021-07-05 08:36:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 10:19:10 +00:00
|
|
|
func PrivacyPolicyAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
2021-07-05 08:36:51 +00: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 10:19:10 +00:00
|
|
|
func PrivacyPolicyChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
2021-07-05 08:36:51 +00:00
|
|
|
e, err := policy.PrivacyPolicyChangedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &PrivacyPolicyChangedEvent{PrivacyPolicyChangedEvent: *e.(*policy.PrivacyPolicyChangedEvent)}, nil
|
|
|
|
}
|