2021-07-05 10:36:51 +02:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-01-03 09:19:07 +01:00
|
|
|
|
2021-07-05 10:36:51 +02:00
|
|
|
"github.com/caos/logging"
|
|
|
|
"github.com/caos/zitadel/internal/domain"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Step17 struct {
|
|
|
|
PrivacyPolicy domain.PrivacyPolicy
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Step17) Step() domain.Step {
|
|
|
|
return domain.Step17
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Step17) execute(ctx context.Context, commandSide *Commands) error {
|
|
|
|
return commandSide.SetupStep17(ctx, s)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Commands) SetupStep17(ctx context.Context, step *Step17) error {
|
2022-01-03 09:19:07 +01:00
|
|
|
fn := func(iam *IAMWriteModel) ([]eventstore.Command, error) {
|
2021-07-05 10:36:51 +02:00
|
|
|
iamAgg := IAMAggregateFromWriteModel(&iam.WriteModel)
|
|
|
|
addedPolicy := NewIAMPrivacyPolicyWriteModel()
|
|
|
|
events, err := c.addDefaultPrivacyPolicy(ctx, iamAgg, addedPolicy, &step.PrivacyPolicy)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
logging.Log("SETUP-N9sq2").Info("default privacy policy set up")
|
2022-01-03 09:19:07 +01:00
|
|
|
return []eventstore.Command{events}, nil
|
2021-07-05 10:36:51 +02:00
|
|
|
}
|
|
|
|
return c.setup(ctx, step, fn)
|
|
|
|
}
|