fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event

This commit is contained in:
Iraq Jaber
2025-08-08 10:18:22 +01:00
parent 53811a1fd8
commit aa281e1e2b
7 changed files with 163 additions and 159 deletions

View File

@@ -3,7 +3,6 @@ package projection
import (
"context"
"encoding/json"
"fmt"
"github.com/zitadel/zitadel/backend/v3/domain"
"github.com/zitadel/zitadel/backend/v3/storage/database/dialect/postgres"
@@ -81,10 +80,6 @@ func (p *idpRelationalProjection) Reducers() []handler.AggregateReducer {
Event: instance.IDPJWTConfigChangedEventType,
Reduce: p.reduceJWTRelationalConfigChanged,
},
// {
// Event: instance.InstanceRemovedEventType,
// Reduce: reduceInstanceRemovedHelper(IDPInstanceIDCol),
// },
},
},
{
@@ -126,10 +121,6 @@ func (p *idpRelationalProjection) Reducers() []handler.AggregateReducer {
Event: org.IDPJWTConfigChangedEventType,
Reduce: p.reduceJWTRelationalConfigChanged,
},
// {
// Event: org.OrgRemovedEventType,
// Reduce: p.reduceOwnerRemoved,
// },
},
},
}
@@ -150,10 +141,6 @@ func (p *idpRelationalProjection) reduceIDPRelationalAdded(event eventstore.Even
if idpEvent.Aggregate().ResourceOwner != idpEvent.Agg.InstanceID {
orgId = &idpEvent.Aggregate().ResourceOwner
}
fmt.Printf("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> idpEvent.Aggregate().InstanceID = %+v\n", idpEvent.Aggregate().InstanceID)
fmt.Printf("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> idpEvent.Aggregate().ResourceOwner = %+v\n", idpEvent.Aggregate().ResourceOwner)
fmt.Printf("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> idpEvent.Aggregate() = %+v\n", idpEvent.Aggregate())
fmt.Printf("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> REDUCE ADD orgId = %+v\n", orgId)
return handler.NewCreateStatement(
&idpEvent,

View File

@@ -48,36 +48,6 @@ func (p *idpTemplateRelationalProjection) Reducers() []handler.AggregateReducer
{
Aggregate: instance.AggregateType,
EventReducers: []handler.EventReducer{
// TODO
// {
// Event: instance.IDPConfigAddedEventType,
// Reduce: p.reduceOldConfigAdded,
// },
// TODO
// {
// Event: instance.IDPConfigChangedEventType,
// Reduce: p.reduceOldConfigChanged,
// },
// TODO
// {
// Event: instance.IDPOIDCConfigAddedEventType,
// Reduce: p.reduceOldOIDCConfigAdded,
// },
// TODO
// {
// Event: instance.IDPOIDCConfigChangedEventType,
// Reduce: p.reduceOldOIDCConfigChanged,
// },
// TODO
// {
// Event: instance.IDPJWTConfigAddedEventType,
// Reduce: p.reduceOldJWTConfigAdded,
// },
// TODO
// {
// Event: instance.IDPJWTConfigChangedEventType,
// Reduce: p.reduceOldJWTConfigChanged,
// },
{
Event: instance.OAuthIDPAddedEventType,
Reduce: p.reduceOAuthIDPRelationalAdded,
@@ -182,18 +152,10 @@ func (p *idpTemplateRelationalProjection) Reducers() []handler.AggregateReducer
Event: instance.SAMLIDPChangedEventType,
Reduce: p.reduceSAMLIDPChanged,
},
// {
// Event: instance.IDPConfigRemovedEventType,
// Reduce: p.reduceIDPConfigRemoved,
// },
{
Event: instance.IDPRemovedEventType,
Reduce: p.reduceIDPRemoved,
},
// {
// Event: instance.InstanceRemovedEventType,
// Reduce: reduceInstanceRemovedHelper(IDPTemplateInstanceIDCol),
// },
},
},
{
@@ -2115,6 +2077,9 @@ func (p *idpTemplateRelationalProjection) reduceSAMLIDPChanged(event eventstore.
// }
func (p *idpTemplateRelationalProjection) reduceIDPRemoved(event eventstore.Event) (*handler.Statement, error) {
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> REMOVE IDPPPPPPPPPPPPPPPP")
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> REMOVE IDPPPPPPPPPPPPPPPP")
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> REMOVE IDPPPPPPPPPPPPPPPP")
var idpEvent idp.RemovedEvent
switch e := event.(type) {
case *org.IDPRemovedEvent:
@@ -2122,14 +2087,34 @@ func (p *idpTemplateRelationalProjection) reduceIDPRemoved(event eventstore.Even
case *instance.IDPRemovedEvent:
idpEvent = e.RemovedEvent
default:
return nil, zerrors.ThrowInvalidArgumentf(nil, "HANDL-xbcvwin2", "reduce.wrong.event.type %v", []eventstore.EventType{org.IDPRemovedEventType, instance.IDPRemovedEventType})
return nil, zerrors.ThrowInvalidArgumentf(nil, "HANDL-Ybcvwin2", "reduce.wrong.event.type %v", []eventstore.EventType{org.IDPRemovedEventType, instance.IDPRemovedEventType})
}
var orgId *string
if idpEvent.Aggregate().ResourceOwner != idpEvent.Agg.InstanceID {
orgId = &idpEvent.Aggregate().ResourceOwner
}
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> REMOVE IDPPPPPPPPPPPPPPPP")
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> REMOVE IDPPPPPPPPPPPPPPPP")
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> REMOVE IDPPPPPPPPPPPPPPPP")
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> REMOVE IDPPPPPPPPPPPPPPPP")
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> REMOVE IDPPPPPPPPPPPPPPPP")
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> REMOVE IDPPPPPPPPPPPPPPPP")
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> REMOVE IDPPPPPPPPPPPPPPPP")
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> REMOVE IDPPPPPPPPPPPPPPPP")
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> REMOVE IDPPPPPPPPPPPPPPPP")
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> REMOVE IDPPPPPPPPPPPPPPPP")
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> REMOVE IDPPPPPPPPPPPPPPPP")
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> REMOVE IDPPPPPPPPPPPPPPPP")
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> REMOVE IDPPPPPPPPPPPPPPPP")
return handler.NewDeleteStatement(
&idpEvent,
[]handler.Condition{
handler.NewCond(IDPTemplateIDCol, idpEvent.ID),
handler.NewCond(IDPTemplateInstanceIDCol, idpEvent.Aggregate().InstanceID),
handler.NewCond(IDPRelationalOrgId, orgId),
},
), nil
}
@@ -2830,12 +2815,10 @@ func reduceSAMLIDPRelationalChangedColumns(payload *domain.SAML, idpEvent *idp.S
if idpEvent.Metadata != nil {
payloadChange = true
payload.Metadata = idpEvent.Metadata
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> METTTADATA")
}
if idpEvent.Key != nil {
payloadChange = true
payload.Key = idpEvent.Key
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> KEEEEEEEEEEEEEEY")
}
if idpEvent.Certificate != nil {
payloadChange = true
@@ -2844,7 +2827,6 @@ func reduceSAMLIDPRelationalChangedColumns(payload *domain.SAML, idpEvent *idp.S
if idpEvent.Binding != nil {
payloadChange = true
payload.Binding = *idpEvent.Binding
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> BINDING")
}
if idpEvent.WithSignedRequest != nil {
payloadChange = true

View File

@@ -144,7 +144,7 @@ func Create(ctx context.Context, sqlClient *database.DB, es handler.EventStore,
IDPUserLinkProjection = newIDPUserLinkProjection(ctx, applyCustomConfig(projectionConfig, config.Customizations["idp_user_links"]))
IDPLoginPolicyLinkProjection = newIDPLoginPolicyLinkProjection(ctx, applyCustomConfig(projectionConfig, config.Customizations["idp_login_policy_links"]))
IDPTemplateProjection = newIDPTemplateProjection(ctx, applyCustomConfig(projectionConfig, config.Customizations["idp_templates"]))
IDPTemplateRelationalProjection = newIDPTemplateRelationalProjection(ctx, applyCustomConfig(projectionConfig, config.Customizations["idp_templates-relational"]))
IDPTemplateRelationalProjection = newIDPTemplateRelationalProjection(ctx, applyCustomConfig(projectionConfig, config.Customizations["idp_templates_relational"]))
MailTemplateProjection = newMailTemplateProjection(ctx, applyCustomConfig(projectionConfig, config.Customizations["mail_templates"]))
MessageTextProjection = newMessageTextProjection(ctx, applyCustomConfig(projectionConfig, config.Customizations["message_texts"]))
CustomTextProjection = newCustomTextProjection(ctx, applyCustomConfig(projectionConfig, config.Customizations["custom_texts"]))