zitadel/internal/management/repository/eventsourcing/view/privacy_policy.go
Fabi beb1c1604a
feat: Privacy policy (#1957)
* feat: command side privacy policy

* feat: add privacy policy to api

* feat: add privacy policy query side

* fix: add privacy policy to mgmt api

* fix: add privacy policy to auth and base data

* feat: use privacyPolicy in login gui

* feat: use privacyPolicy in login gui

* feat: test org fatures

* feat: typos

* feat: tos in register
2021-07-05 10:36:51 +02:00

54 lines
1.7 KiB
Go

package view
import (
"github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore/v1/models"
"github.com/caos/zitadel/internal/iam/repository/view"
"github.com/caos/zitadel/internal/iam/repository/view/model"
global_view "github.com/caos/zitadel/internal/view/repository"
)
const (
privacyPolicyTable = "management.privacy_policies"
)
func (v *View) PrivacyPolicyByAggregateID(aggregateID string) (*model.PrivacyPolicyView, error) {
return view.GetPrivacyPolicyByAggregateID(v.Db, privacyPolicyTable, aggregateID)
}
func (v *View) PutPrivacyPolicy(policy *model.PrivacyPolicyView, event *models.Event) error {
err := view.PutPrivacyPolicy(v.Db, privacyPolicyTable, policy)
if err != nil {
return err
}
return v.ProcessedPrivacyPolicySequence(event)
}
func (v *View) DeletePrivacyPolicy(aggregateID string, event *models.Event) error {
err := view.DeletePrivacyPolicy(v.Db, privacyPolicyTable, aggregateID)
if err != nil && !errors.IsNotFound(err) {
return err
}
return v.ProcessedPrivacyPolicySequence(event)
}
func (v *View) GetLatestPrivacyPolicySequence() (*global_view.CurrentSequence, error) {
return v.latestSequence(privacyPolicyTable)
}
func (v *View) ProcessedPrivacyPolicySequence(event *models.Event) error {
return v.saveCurrentSequence(privacyPolicyTable, event)
}
func (v *View) UpdatePrivacyPolicySpoolerRunTimestamp() error {
return v.updateSpoolerRunSequence(privacyPolicyTable)
}
func (v *View) GetLatestPrivacyPolicyFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
return v.latestFailedEvent(privacyPolicyTable, sequence)
}
func (v *View) ProcessedPrivacyPolicyFailedEvent(failedEvent *global_view.FailedEvent) error {
return v.saveFailedEvent(failedEvent)
}