fix: change to repository event types and removed unused code (#3386)

* fix: change to repository event types and removed unused code

* some fixes

* remove unused code
This commit is contained in:
Livio Amstutz
2022-03-31 11:36:26 +02:00
committed by GitHub
parent 55af4a18a2
commit 87560157c1
170 changed files with 999 additions and 9581 deletions
@@ -7,9 +7,9 @@ import (
"github.com/caos/logging"
caos_errs "github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore"
"github.com/caos/zitadel/internal/eventstore/v1/models"
"github.com/caos/zitadel/internal/user/model"
es_model "github.com/caos/zitadel/internal/user/repository/eventsourcing/model"
user_repo "github.com/caos/zitadel/internal/repository/user"
)
const (
@@ -32,47 +32,11 @@ type ExternalIDPView struct {
InstanceID string `json:"instanceID" gorm:"column:instance_id"`
}
func ExternalIDPViewFromModel(externalIDP *model.ExternalIDPView) *ExternalIDPView {
return &ExternalIDPView{
UserID: externalIDP.UserID,
IDPConfigID: externalIDP.IDPConfigID,
ExternalUserID: externalIDP.ExternalUserID,
IDPName: externalIDP.IDPName,
UserDisplayName: externalIDP.UserDisplayName,
Sequence: externalIDP.Sequence,
CreationDate: externalIDP.CreationDate,
ChangeDate: externalIDP.ChangeDate,
ResourceOwner: externalIDP.ResourceOwner,
}
}
func ExternalIDPViewToModel(externalIDP *ExternalIDPView) *model.ExternalIDPView {
return &model.ExternalIDPView{
UserID: externalIDP.UserID,
IDPConfigID: externalIDP.IDPConfigID,
ExternalUserID: externalIDP.ExternalUserID,
IDPName: externalIDP.IDPName,
UserDisplayName: externalIDP.UserDisplayName,
Sequence: externalIDP.Sequence,
CreationDate: externalIDP.CreationDate,
ChangeDate: externalIDP.ChangeDate,
ResourceOwner: externalIDP.ResourceOwner,
}
}
func ExternalIDPViewsToModel(externalIDPs []*ExternalIDPView) []*model.ExternalIDPView {
result := make([]*model.ExternalIDPView, len(externalIDPs))
for i, r := range externalIDPs {
result[i] = ExternalIDPViewToModel(r)
}
return result
}
func (i *ExternalIDPView) AppendEvent(event *models.Event) (err error) {
i.Sequence = event.Sequence
i.ChangeDate = event.CreationDate
switch event.Type {
case es_model.HumanExternalIDPAdded:
switch eventstore.EventType(event.Type) {
case user_repo.UserIDPLinkAddedType:
i.setRootData(event)
i.CreationDate = event.CreationDate
err = i.SetData(event)