mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 18:33:28 +00:00
hope this works
This commit is contained in:
@@ -89,13 +89,24 @@ func (p *instanceDomainRelationalProjection) reduceDomainPrimarySet(event events
|
||||
return zerrors.ThrowInvalidArgumentf(nil, "HANDL-QnjHo", "reduce.wrong.db.pool %T", ex)
|
||||
}
|
||||
domainRepo := repository.InstanceRepository(v3_sql.SQLTx(tx)).Domains(false)
|
||||
|
||||
condition := database.And(
|
||||
domainRepo.InstanceIDCondition(e.Aggregate().InstanceID),
|
||||
domainRepo.DomainCondition(database.TextOperationEqual, e.Domain),
|
||||
domainRepo.TypeCondition(domain.DomainTypeCustom),
|
||||
)
|
||||
|
||||
_, err := domainRepo.Update(ctx,
|
||||
database.And(
|
||||
domainRepo.InstanceIDCondition(e.Aggregate().InstanceID),
|
||||
domainRepo.DomainCondition(database.TextOperationEqual, e.Domain),
|
||||
domainRepo.TypeCondition(domain.DomainTypeCustom),
|
||||
),
|
||||
condition,
|
||||
domainRepo.SetPrimary(),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// we need to split the update into two statements because multiple events can have the same creation date
|
||||
// therefore we first do not set the updated_at timestamp
|
||||
_, err = domainRepo.Update(ctx,
|
||||
condition,
|
||||
domainRepo.SetUpdatedAt(e.CreationDate()),
|
||||
)
|
||||
return err
|
||||
|
@@ -86,13 +86,22 @@ func (p *orgDomainRelationalProjection) reducePrimarySet(event eventstore.Event)
|
||||
return zerrors.ThrowInvalidArgumentf(nil, "HANDL-h6xF0", "reduce.wrong.db.pool %T", ex)
|
||||
}
|
||||
domainRepo := repository.OrganizationRepository(v3_sql.SQLTx(tx)).Domains(false)
|
||||
condition := database.And(
|
||||
domainRepo.InstanceIDCondition(e.Aggregate().InstanceID),
|
||||
domainRepo.OrgIDCondition(e.Aggregate().ResourceOwner),
|
||||
domainRepo.DomainCondition(database.TextOperationEqual, e.Domain),
|
||||
)
|
||||
_, err := domainRepo.Update(ctx,
|
||||
database.And(
|
||||
domainRepo.InstanceIDCondition(e.Aggregate().InstanceID),
|
||||
domainRepo.OrgIDCondition(e.Aggregate().ResourceOwner),
|
||||
domainRepo.DomainCondition(database.TextOperationEqual, e.Domain),
|
||||
),
|
||||
condition,
|
||||
domainRepo.SetPrimary(),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// we need to split the update into two statements because multiple events can have the same creation date
|
||||
// therefore we first do not set the updated_at timestamp
|
||||
_, err = domainRepo.Update(ctx,
|
||||
condition,
|
||||
domainRepo.SetUpdatedAt(e.CreationDate()),
|
||||
)
|
||||
return err
|
||||
@@ -141,13 +150,23 @@ func (p *orgDomainRelationalProjection) reduceVerificationAdded(event eventstore
|
||||
return zerrors.ThrowInvalidArgumentf(nil, "HANDL-yF03i", "reduce.wrong.db.pool %T", ex)
|
||||
}
|
||||
domainRepo := repository.OrganizationRepository(v3_sql.SQLTx(tx)).Domains(false)
|
||||
condition := database.And(
|
||||
domainRepo.InstanceIDCondition(e.Aggregate().InstanceID),
|
||||
domainRepo.OrgIDCondition(e.Aggregate().ResourceOwner),
|
||||
domainRepo.DomainCondition(database.TextOperationEqual, e.Domain),
|
||||
)
|
||||
|
||||
_, err := domainRepo.Update(ctx,
|
||||
database.And(
|
||||
domainRepo.InstanceIDCondition(e.Aggregate().InstanceID),
|
||||
domainRepo.OrgIDCondition(e.Aggregate().ResourceOwner),
|
||||
domainRepo.DomainCondition(database.TextOperationEqual, e.Domain),
|
||||
),
|
||||
condition,
|
||||
domainRepo.SetValidationType(validationType),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// we need to split the update into two statements because multiple events can have the same creation date
|
||||
// therefore we first do not set the updated_at timestamp
|
||||
_, err = domainRepo.Update(ctx,
|
||||
condition,
|
||||
domainRepo.SetUpdatedAt(e.CreationDate()),
|
||||
)
|
||||
return err
|
||||
@@ -165,15 +184,27 @@ func (p *orgDomainRelationalProjection) reduceVerified(event eventstore.Event) (
|
||||
return zerrors.ThrowInvalidArgumentf(nil, "HANDL-0ZGqC", "reduce.wrong.db.pool %T", ex)
|
||||
}
|
||||
domainRepo := repository.OrganizationRepository(v3_sql.SQLTx(tx)).Domains(false)
|
||||
|
||||
condition := database.And(
|
||||
domainRepo.InstanceIDCondition(e.Aggregate().InstanceID),
|
||||
domainRepo.OrgIDCondition(e.Aggregate().ResourceOwner),
|
||||
domainRepo.DomainCondition(database.TextOperationEqual, e.Domain),
|
||||
)
|
||||
|
||||
_, err := domainRepo.Update(ctx,
|
||||
database.And(
|
||||
domainRepo.InstanceIDCondition(e.Aggregate().InstanceID),
|
||||
domainRepo.OrgIDCondition(e.Aggregate().ResourceOwner),
|
||||
domainRepo.DomainCondition(database.TextOperationEqual, e.Domain),
|
||||
),
|
||||
condition,
|
||||
domainRepo.SetVerified(),
|
||||
domainRepo.SetUpdatedAt(e.CreationDate()),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// we need to split the update into two statements because multiple events can have the same creation date
|
||||
// therefore we first do not set the updated_at timestamp
|
||||
_, err = domainRepo.Update(ctx,
|
||||
condition,
|
||||
domainRepo.SetUpdatedAt(e.CreationDate()),
|
||||
)
|
||||
return err
|
||||
}), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user